I have a multipart format text file. i am going threw the file looking for start of content and from then on writing the content to another file until i hit end of content.
FileInputStream in = new FileInputStream(getContentPath());
InputStreamReader sr = new InputStreamReader(in, "UTF-8");
BufferedReader buffreader = new BufferedReader(sr);
String lineStr;
while ((lineStr = buffreader.readLine()) != null) {
if (lineStr == "") {
FileOutputStream fos = new FileOutputStream("", true);
OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8");
BufferedWriter fbw = new BufferedWriter(writer);
fbw.write(lineStr);
fbw.newLine();
fbw.flush();
fbw.close();
}
}
The problem i am getting is the resulting files encoding is all messed up. The input is utf8.
Just image file extracted(funny-pictures-bomb-squad-cat-chooses-the-blue-wire.jpg)
Found problem the input charset was not utf8 it is iso-8859-1 http default.
Used CharsetDecoder to make sure i read/saved string as iso-8859-1.