/** * Converts hc.txt to hc.dat for hits count applet hc.class * @author Robert J Morton UK-YE572246C * @version 27 April 2000 */ // This program uses the Java 1.1.8 API. import java.io.*; class tlitxdat { public static void main(String args[]) throws IOException { BufferedReader r = new BufferedReader( new InputStreamReader( new FileInputStream("tlisales.txt") ) ); DataOutputStream w = new DataOutputStream( new FileOutputStream("tlisales.dat") ); String s; int x; while((s = r.readLine()) != null) { // read in the next line of text int l = s.length(); // get its length /* If there are more than 8 characters, it is a valid entry, so extract the number of hits for that week. */ if (l > 8 && !s.substring(0,1).equals("#")) x = Integer.parseInt(s.substring(8, l)); else x = -1; // indicates a null entry w.writeByte(x); // write the integer as a single signed byte value } w.close(); r.close(); } }