• Post Reply Bookmark Topic Watch Topic
  • New Topic

readRecord()

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To correct the deprecated methods one needs to use the String constructor which allows for the encoding to be specified. By using the
public String(byte[] bytes,
int offset,
int length,
String enc)
throws UnsupportedEncodingException
constrcutor. I note that it also throws an IndexOutOfBoundsException.
My question is where do people consider the best place to catch and handle this exception???
 
Marco Poehler
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can use the constructor:
String( bytes[] ascii, int offset, int length )
which uses the platforms default character encoding.
right ?
marco
Originally posted by benjamin wheeler:
To correct the deprecated methods one needs to use the String constructor which allows for the encoding to be specified. By using the
public String(byte[] bytes,
int offset,
int length,
String enc)
throws UnsupportedEncodingException
constrcutor. I note that it also throws an IndexOutOfBoundsException.
My question is where do people consider the best place to catch and handle this exception???

 
Thomas Mathai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marco Poehler:
I think you can use the constructor:
String( bytes[] ascii, int offset, int length )
which uses the platforms default character encoding.
right ?
marco


IMHO, you do not really want to leave it to the platform's default encoding. Your binary file db.db uses only 1 byte per character. So you would want to enforce ISO-8859-1 encoding.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!