473,396 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

print new line in files

how can I print new line in a file using a reference to Formatter object

Expand|Select|Wrap|Line Numbers
  1. //create reference to file to read from
  2. Scanner input=new Scanner(new File("d:\\records1.txt"));
  3.  
  4. //create reference to file to write
  5. Formatter output=new Formatter("d:\\records7.txt");
  6.  
  7. while(input.hasNext()){
  8.  
  9.            output.format(input.nextLine());
  10.            output.format();
  11. }
what should I print in output.format() to promote the file to inter new line before printing the next line that it reads from input
Mar 20 '07 #1
4 14271
sicarie
4,677 Expert Mod 4TB
how can I print new line in a file using a reference to Formatter object

Expand|Select|Wrap|Line Numbers
  1. //create reference to file to read from
  2. Scanner input=new Scanner(new File("d:\\records1.txt"));
  3.  
  4. //create reference to file to write
  5. Formatter output=new Formatter("d:\\records7.txt");
  6.  
  7. while(input.hasNext()){
  8.  
  9.            output.format(input.nextLine());
  10.            output.format();
  11. }
what should I print in output.format() to promote the file to inter new line before printing the next line that it reads from input
You could do that a few different ways, either output.newLine(); or use '\n' the newline character.
Mar 20 '07 #2
You could do that a few different ways, either output.newLine(); or use '\n' the newline character.
no that is not allowed class Formatter dont include method newLine
so I can't use newLine() on Formatter object
an also when I wite
output.format("/n") it print /n in the file
if I print output.format(/n) also there is error
Mar 20 '07 #3
sicarie
4,677 Expert Mod 4TB
no that is not allowed class Formatter dont include method newLine
so I can't use newLine() on Formatter object
an also when I wite
output.format("/n") it print /n in the file
if I print output.format(/n) also there is error
Your slash is pointed the wrong direction. Try "\n".
Mar 20 '07 #4
you are suppose to write "\n" instead of writing "/n" or /n

e.g.

output.format("\n");


I hope this will work
Mar 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the...
4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
5
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
2
by: G | last post by:
I am trying to duplicate the printing of a shortcut-print of an access report in my NT Scheduled Tasks. I can now print the report manually very easily by right-clicking on a shortcut to the access...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
12
by: Jchick | last post by:
Boy, this should be a simple bit of code but I can't figure out how to make it happen. I have a CSV file shows up in a directory that has 4 fields that need to be printed on labels. Each line of...
4
by: PengYu.UT | last post by:
Suppose I have a dos format text file. The following python code will print ^M at the end. I'm wondering how to print it in unix format. fh = open(options.filename) for line in fh.readlines()...
13
by: damonwischik | last post by:
I'd like to print out a unicode string. I'm running Python inside Emacs, which understands utf-8, so I want to force Python to send utf-8 to sys.stdout. From what I've googled, I think I need...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
1
by: grego9 | last post by:
I am trying to write a macro that will print all files in a particular folder. The folder will always have the same name - but the number of files in that folder may differ. I simply want a macro...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.