Stream to be stored in bytes with UTF or ISO-8859-1 encoding format?
807569May 25 2006 — edited May 26 2006Is 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