• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pagebreaks in a text file

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:
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
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
}
}
reply
    Bookmark Topic Watch Topic
  • New Topic