Line-Splitter

Dr. Andrew Broad
Computer Science
Java
Line-Splitter


Ever had the experience of wanting to print a text-file, but the printer would truncate lines longer than 80 characters (say), so you have to go through the file by hand, inserting newlines so that all the text will be printed? I have, so I wrote a program to automate splitting the overlength lines.

Line-Splitter is a simple Java program for splitting overlength lines in text-files by inserting newlines. If you want proper word-wrap or indentation it's not for you, but I find it to be quite useful for processing any source-code files that have overlength lines.

Line-Splitter has a simple command-line interface - no faffing around with pointless GUIs! ;-) Say you wanted to split a text-file called Makefile to a maximum line-length of 78 (I regularly want to print a makefile on a printer that truncates lines longer than 78 columns) - the following command-line would do the job:

java Lines Makefile 78 > ~/LASERJET2/Makefile
(The program writes its output to the standard output stream, so the above command redirects it to a file, which can subsequently be printed. Do not attempt to overwrite the input-file with the output-file, as this will wipe the input-file and leave a 0-length file.)

If the maximum line-length is omitted from the command-line, Line-Splitter just tells you the length of the longest line in the file:

java Lines MakefileMaximum line length is 1175.


Email me
Hosted by www.Geocities.ws

1