dcsimg
Formatting a text file using JAVA program
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abha_Salhotra
Posted On:   Tuesday, February 3, 2004 03:07 AM

Sir/Madam



How can i format the contents of the file, like say, i want to write something in new line.



Regards

Re: Formatting a text file using JAVA program

Posted By:   David_Thornton  
Posted On:   Wednesday, March 3, 2004 05:04 PM



Java escape sequences and the special characters they represent;



 Backspace
Horizontal tab
v Vertical tab

New line
 Backspace
f FormFeed
Carriage return
" Double quote
\' Single quote
\ Backslash


For example;



File newFile = new File("C:\myfolder\myfile.txt");
FileOutputStream newFileOutputStream = new java.io.FileOutputStream(newFile);
java.io.PrintStream newPrintStream = new java.io.PrintStream(newFileOutputStream);
newPrintStream.flush();
newPrintStream.println("This will print a line of text followed by carriage return line feed
");
newPrintStream.println("so this text will be on a new line when viewed in Notepad
");
newPrintStream.println("and this text will be
split over two lines
");
newPrintStream.flush();
newPrintStream.close();

Re: Formatting a text file using JAVA program

Posted By:   Thirupathi_pandiaraj  
Posted On:   Tuesday, March 2, 2004 11:20 AM

Hai this is an example

Re: Formatting a text file using JAVA program

Posted By:   Anonymous  
Posted On:   Tuesday, February 10, 2004 01:18 AM


HI..
pls check java.io.RandomAccessFile.
Hope that class will help u.
Thanks
About | Sitemap | Contact