C:\ece538>java FileChange1 GFG.java test1.htmlproduces test1.html
FileChange1.java
import java.io.*; class FileChange1 { public static void main( String[] args ) { int ch = 0; if ( args.length != 2 ) { System.err.println( "usage: java FileChange1 source dest" ); System.exit( 0 ); } byte [] equals = "EQUALS".getBytes(); try ( FileInputStream in = new FileInputStream( args[0] ); FileOutputStream out = new FileOutputStream( args[1] ); ) { out.write(String.format("<html>%n").getBytes()); out.write(String.format("<pre>%n").getBytes()); while ( true ) { ch = in.read(); if (ch == -1) break; else if (ch == '=') out.write(equals); else out.write(ch); } out.write(String.format("</pre>%n").getBytes()); out.write(String.format("</html>%n").getBytes()); out.close(); in.close(); } catch (IOException e) { System.err.println( "IO error "+e ); } } }
Maintained by John Loomis, updated Tue Feb 04 20:45:37 2020