Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintWriter line length

Status
Not open for further replies.

yahve

Programmer
Nov 14, 2000
159
0
0
CA
Hi,

I'm writing to a text file using FileWriter and PrintWriter and I want to know how to specify the lines length (ie 80).
Is there a way to do this?

Thank you.
 
you cannot set a line length if the FileWriter and PrintWriter classes. To have this feature I would extends the class and provide the functionality you want.

For example, you might create a method setMaxLineLength(int l), and override the print(String s) and println(String s) methods. If a String is passed with length greater than the maxLineLength, then split the String up into lengths less than or equal to the maxLinLength and use the super.println(String s) call.

hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top