
Hi this is venkatesh goud. I have written program for writing given string into .txt file but it is not displaying output currectly please give me solution for bellow problem. the control is not transfering to new line when \n used. But when i am opening this text file in wordpad or ms-word it is displaying currectly. I am usins windows XP service pack-2 operating system...
import java.io.*;
class BRRead {
public static void main(String args[])
throws IOException
{
String s="fjdsjf;sdj;f \n"+"sddddddddddddddddd \n"+"sdgggggggggggggggggggg \n";
FileWriter fw=new FileWriter("c:/hello.doc");
for (int i=0;i<s.length() ;i++ )
{
fw.write(s.charAt(i));
}
fw.close();
FileOutputStream fos=new FileOutputStream("c:/myfile1.txt");
String ch="Now is the time for all good men\n"+ " to come to the aid of their country\t ddd \n"+ " and pay their due taxes.";
byte[] b=ch.getBytes();
fos.write(b);
fos.close();
}
}
the output displaying in same line and instead of new line(\n) small square displaying please send me solution
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.