import java.io.*; import java.lang.*; import java.util.regex.*; class readtxt { // main, list, listnum, converttohtm // ====================================================== // change from j0203.java public static void main(String args[]) throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String buf; System.out.println("0 : bye bye"); System.out.println("1 : List this source code of readtxt.java"); System.out.println("2 : List source code on demand"); System.out.println("3 : Convert readtxt.java to readtxt.htm"); System.out.println(""); System.out.print("Wait your choice [0,1,2,3 or bye] : "); buf = stdin.readLine(); while (!buf.equals("0")) { if (buf.equals("0") || buf.equals("bye")) { System.out.println("Bye Bye"); break; } else if (buf.equals("1")) { list("readtxt.java"); buf = " "; } else if (buf.equals("2")) { listnum(); buf = " "; } else if (buf.equals("3")) { converttohtm(); buf = " "; } else { System.out.print("Wait your choice [0,1,2,3 or bye] : "); buf = stdin.readLine(); // buf = (char)System.in.read(); // for 1 character } } } // ====================================================== // change from j0603.java public static void list (String f) throws IOException { int n = 0; byte b[] = new byte[128]; FileInputStream fin = new FileInputStream(f); while ((n = fin.read(b)) != -1) { for(int i=0;i"); pout.println("td{font-family:fixedsys;font-size:10px;}"); pout.println(""); pout.println(""); while ((b = bin.readLine()) != null) { // String bnew = b.replace('a', 'A'); Pattern pattern = Pattern.compile("&"); Matcher matcher = pattern.matcher(b); b = matcher.replaceAll("&"); // pattern = Pattern.compile(">"); matcher = pattern.matcher(b); b = matcher.replaceAll(">"); // pattern = Pattern.compile("<"); matcher = pattern.matcher(b); b = matcher.replaceAll("<"); // pattern = Pattern.compile(" "); matcher = pattern.matcher(b); b = matcher.replaceAll(" "); pout.println(""); pout.println(""); pout.println(""); pout.println(""); i = i + 1; } pout.println("
"+i+""+b+"
"); System.out.println("Use IE to open readtxt.htm"); fin.close(); pout.close(); } }