Input and output in Java
Posted on 2003-02-28
A standard data processing task is to read and modify the contents of one file, writing the results to a second file. Write a Java program that performs this task, where
the names of the input file and output file are provided by the user on the command line when the program is run. This program should check that these two arguments are provided, that the first is a file that is not a directory, and that the second is not an existing file. Hint: the File class provides suitable methods.
the contents of the input file should be read in one byte at a time. Hint: read() either returns an integer between 0 and 255 (the value of an unsigned byte) or -1 (upon reaching the end of the input stream).
each byte read should be written to the output file as soon as it is available, except that (i) the value 36 should be changed to the value 163, (ii) the value 10 should be inserted after the value 12, and (iii) if the value 111 is immediately followed by the value 101, they should be replaced by the single value 248.