Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Stream to be stored in bytes with UTF or ISO-8859-1 encoding format?

807569May 25 2006 — edited May 26 2006
Is there any possibility of converting stream to bytes with ISO encoding I am able to encode string to bytes and decode byte to string by using charset encoding/decoding in java.
I am trying to read French spanish files.

for reding like this char supports not byte:

BufferedReader rdr = new BufferedReader(new InputStreamReader (new FileInputStream (filePath),
"ISO-8859-1"));

So this is the way i am trying:

FileInputStream stream = new FileInputStream (f);

byte[] buffer = new byte [size];

/* Charset cs = Charset.forName( "ISO-8859-1" ); //encoding
ByteBuffer bb = ByteBuffer.wrap( buffer );
CharBuffer cb = cs.decode( bb );
// String s = cb.toString();
*/
stream.read (buffer, 0, size);
stream.close();
aMap.put ("content", new ByteBlock (buffer, name, mimeType));


Vijendra
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2006
Added on May 25 2006
5 comments
777 views