P
Perma
Hi,
I have a Java program which polls a directory for incoming files
(zipped and text).
When a new file comes, I read it and post it's outcome.
Here I have some encoding problems. The text files are usually UTF-8,
so I hard-code the encoding to UTF-8:
Code extract:
....
// trying to read the file "myFile"
FileInputStream fi = new FileInputStream(myFile);
InputStreamReader ir = new InputStreamReader(fi, "UTF8"); // hardcoded
UTF-8, how can I do this dynamically?
....
I was expecting the zipped files to be UTF-8 as well, but it turned
out not to be, so I get an:
MalformedInputException at
sun.io.ByteToCharUTF8.convert([BII[CII)I(ByteToCharUTF8
So I have to handle the two separately and it troubles my code.
I guess there's a smart way of doing this.
Hope someone can give me some hint on this!
Regards, Per Magnus
I have a Java program which polls a directory for incoming files
(zipped and text).
When a new file comes, I read it and post it's outcome.
Here I have some encoding problems. The text files are usually UTF-8,
so I hard-code the encoding to UTF-8:
Code extract:
....
// trying to read the file "myFile"
FileInputStream fi = new FileInputStream(myFile);
InputStreamReader ir = new InputStreamReader(fi, "UTF8"); // hardcoded
UTF-8, how can I do this dynamically?
....
I was expecting the zipped files to be UTF-8 as well, but it turned
out not to be, so I get an:
MalformedInputException at
sun.io.ByteToCharUTF8.convert([BII[CII)I(ByteToCharUTF8
So I have to handle the two separately and it troubles my code.
I guess there's a smart way of doing this.
Hope someone can give me some hint on this!
Regards, Per Magnus