Perry Smith

Java Questions & Answers

Home / Java Q & A Archive Page 1 / Java Q & A Archive / Java Q & A Main Page

9-16-98

How do I add new line to an output file?

I'm doing a calculation in a java program and saving the output using writeBytes(s) where s is a String variable. The result is an output that is one long line (no "new line" or "line break"). Can anyone tell me how to start a new line so that my output files look nicer? Thanks in advance

R.Berg


Responses
9-18-98

Re: the response. I don't understand how to use /n

Thanks for the quick response. I recognize /n means new line, but I don't know how to communicate to the computer with it. Here's what I tried:
ds.writeByte(/n);
ds.writeByte(s,/n);
s = s+ "/n";
s = s +/n;
ds./n;
/n;
all of which failed except the third line, but that just added the characters /n every place I wanted a line return. Thank you for your patience, but could you explain where I put the /n?

R. Berg


9-21-98

Re: How do I add new line to an output file?

You can concat one +"\n" to the String variable. So that each time the writeBytes(String) method is called one new line will be added.

Best wishes

Samudra


9-22-98

Re: Re: Thanks! That worked!

Thanks to Samudra and all respondees for selflessly helping out!

R. Berg


Home / Java Q & A Archive Page 1 / Java Q & A Archive / Java Q & A Main Page