• 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

insert new line character

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm creating a batch file with two commands in it. I would like to insert a nextline character between these two commands. How do I do that?
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
etovelli-
Welcome to the JavaRanch! Please adjust your displayed name to meet the JavaRanch Naming Policy. You can do so here.
Thanks! and again, Welcome to the Ranch!
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
try to add "\n\r" or "\r\n" between the lines.
Basicly, this is OS dependent. On Windows, it should be enough, to add "\n", but not on Unix systems.
Good luck

Rene
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, if you are talking about inserting the character just so you have the commands on separate lines, like:
command one
command two
you can use the PrintWriter class, it has options to write both on the same line (the print() method), or write one command on one line, and then the next on a new line (the println() method).
You would create the object like this:
PrintWriter write = new PrintWriter( new FileOutputStream( "filename.bat" ) );
And simply call:
write.println( "command one" );
write.println( "command two" );
If you want a whole separate line, something like:
command one
command two
Then you could make three calls like:
write.println( "command one" );
write.println();
write.pritnln( "command two" );
Look at the API for the IO classes, plenty of things there to handle this.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic