FileDocCategorySizeDatePackage
SourceWriter.javaAPI DocExample1514Sun Mar 28 07:23:54 BST 1999com.macfaq.io

SourceWriter

public class SourceWriter extends FilterWriter

Fields Summary
Constructors Summary
public SourceWriter(Writer out)

    super(out); 
  
Methods Summary
public static voidmain(java.lang.String[] args)

  
    for (int i = 0; i < args.length; i++) {
      FileInputStream fin = new FileInputStream(args[i]);
      InputStreamReader r = new InputStreamReader(fin, "UnicodeLittle");
      SourceWriter sw = new SourceWriter(new OutputStreamWriter(System.out));
      int c;
      while ((c = r.read()) != -1) {
        sw.write(c);
      }
      fin.close();
      sw.close();
    }
  
  
public voidwrite(char[] text, int offset, int length)

    
    for (int i = offset; i < offset+length; i++) {
      this.write(text[i]);
    }
    
  
public voidwrite(java.lang.String s, int offset, int length)

    
    for (int i = offset; i < offset+length; i++) {
      this.write(s.charAt(i));
    }
      
  
public voidwrite(int c)

    
    // we have to escape the backslashes below
    if (c == '\\") out.write("\\u005C");
    else if (c < 128) out.write(c);
    else {
      String s = Integer.toHexString(c);
      // pad with leading zeroes if necessary
      if (c < 256) s = "00" + s;
      else if (c < 4096) s = "0" + s;
      out.write("\\u");
      out.write(s);
    }