Hi All,
I have file which contains data in EBCIDC format.The data contains both english and arabic characters.I have to convert into UTF-8.Iam able to convert the data successfully into unicode.But iam losing out newline.All the charaters are appearing in the single line after conversion to unicode.Please help me.What is wrong with this code.
import java.io.*;
class FileRead1
{
public static void main(
String args[])
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("C:\\sabb.txt");
File outfile = new File( "C:\\100.txt" );
FileOutputStream fout = new FileOutputStream( outfile);
// Get the object of DataInputStream
InputStreamReader is = new InputStreamReader( fstream, "cp420");
//DataInputStream in = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(is);
String strLine;
//Read File Line By Line
while ((strLine = reader.readLine()) != null) {
byte[] output =strLine.getBytes("UTF-8" );
fout.write(output);
fout.close();
}
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}