This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Pagebreaks in a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pagebreaks in a text file" Watch "Pagebreaks in a text file" New topic

Pagebreaks in a text file

Shital Kapadia
Ranch Hand

Joined: Jul 19, 2002
Posts: 34
Does anyone know of a way to insert a page break in a text file that is being generated by a java program so that when that file is opened in word, each piece of information gets printed on a separate page.
Many Thanks,
Shital Kapadia
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi Shital,
'\014' is a escape character for page break. Hence you can use the same to get the page break. I have written a sample programe. Run the same redirecting output to a file. that is use the following command after compiling
java PageBreak > text.txt
and open the test.txt in MS-word you will get what you wanted.
public class PageBreak
public static void main(String args[])
System.out.println("First Page");
System.out.println( "\014" );
System.out.println( "Second Page");

Sharing is learning
It is sorta covered in the JavaRanch Style Guide.
subject: Pagebreaks in a text file
Similar Threads
need help
how many ways do two java program communicate?
include contents of an .inc file as in HTML pages
Servlet response.setContentType()??
Struts FormFile (parsing .csv files)