package OT; import java.io.*; /** * Debugging utility. * @version 1998-9-27 * @author Andrea Heiberg, University of Arizona */ public class Debug { DataOutputStream out = null; boolean isApplet; public Debug(boolean isApplet, String filename) { this.isApplet = isApplet; if (!isApplet) { try { out = new DataOutputStream(new FileOutputStream(new File(filename))); } catch (Exception e) { System.out.println(e); } //end try } //end if } //end constructor public void write(String s) { if (!isApplet) { writeApplication(s); } //end if } //end write public void writeApplication(String s) { try { byte[] array = new byte[s.length()]; s.getBytes(0, s.length(), array, 0); for (int i = 0; i < s.length(); i++) { out.writeByte(array[i]); } //end for out.writeByte('\n'); } catch (Exception e) { System.out.println(e); } //end try } //end writeApplication protected void finalize() { try { out.close(); } catch (Exception e) { System.out.println(e); } //end try } //end finalize } //end class