diff --git a/jode/jode/Decompiler.java b/jode/jode/Decompiler.java index ebd8e37..6dfc5d4 100644 --- a/jode/jode/Decompiler.java +++ b/jode/jode/Decompiler.java @@ -55,7 +55,7 @@ public class Decompiler { public static int outputStyle = SUN_STYLE; public static void usage() { - PrintStream err = GlobalOptions.err; + PrintWriter err = GlobalOptions.err; err.println("Version: " + GlobalOptions.version); err.print("use: jode [-v]" +"[--cp ][--dest ]" diff --git a/jode/jode/GlobalOptions.java b/jode/jode/GlobalOptions.java index 9c056eb..b1d4b06 100644 --- a/jode/jode/GlobalOptions.java +++ b/jode/jode/GlobalOptions.java @@ -18,7 +18,7 @@ */ package jode; -import java.io.PrintStream; +import java.io.PrintWriter; import java.util.StringTokenizer; public class GlobalOptions { @@ -29,7 +29,7 @@ public class GlobalOptions { public final static String URL = "http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html"; - public static PrintStream err = System.err; + public static PrintWriter err = new PrintWriter(System.err); public static int verboseLevel = 0; public static int debuggingFlags = 0; diff --git a/jode/jode/JodeWindow.java b/jode/jode/JodeWindow.java index a2434c3..66fd7bb 100644 --- a/jode/jode/JodeWindow.java +++ b/jode/jode/JodeWindow.java @@ -143,7 +143,7 @@ public class JodeWindow startButton.addActionListener(this); saveButton.addActionListener(this); ///#endif - GlobalOptions.err = new PrintStream(new AreaOutputStream(errorArea)); + GlobalOptions.err = new PrintWriter(new AreaWriter(errorArea)); } public void setClasspath(String cp) { @@ -200,27 +200,15 @@ public class JodeWindow } } - public class AreaOutputStream extends OutputStream { + public class AreaWriter extends Writer { boolean initialized = false; private TextArea area; - public AreaOutputStream(TextArea a) { + public AreaWriter(TextArea a) { area = a; } - public void write(int b) throws IOException { - if (!initialized) { - area.setText(""); - initialized = true; - } -///#ifdef AWT10 -/// area.appendText(String.valueOf((char)b)); -///#else - area.append(String.valueOf((char)b)); -///#endif - } - - public void write(byte[] b, int off, int len) throws IOException { + public void write(char[] b, int off, int len) throws IOException { if (!initialized) { area.setText(""); initialized = true; @@ -231,6 +219,12 @@ public class JodeWindow area.append(new String(b, off, len)); ///#endif } + + public void flush() { + } + + public void close() { + } } public void run() { @@ -266,8 +260,7 @@ public class JodeWindow } TabbedPrintWriter writer = - new TabbedPrintWriter(new AreaOutputStream(sourcecodeArea) - , imports); + new TabbedPrintWriter(new AreaWriter(sourcecodeArea), imports); ClassAnalyzer clazzAna = new ClassAnalyzer(null, clazz, imports); clazzAna.dumpJavaFile(writer); diff --git a/jode/jode/obfuscator/Main.java b/jode/jode/obfuscator/Main.java index 7840ea5..0fb049d 100644 --- a/jode/jode/obfuscator/Main.java +++ b/jode/jode/obfuscator/Main.java @@ -22,7 +22,7 @@ import jode.bytecode.ClassInfo; import jode.obfuscator.*; import java.util.Vector; import java.lang.reflect.Modifier; -import java.io.PrintStream; +import java.io.PrintWriter; public class Obfuscator { public static boolean shouldStrip = true; @@ -42,7 +42,7 @@ public class Obfuscator { public static final int RENAME_NONE = 3; public static void usage() { - PrintStream err = GlobalOptions.err; + PrintWriter err = GlobalOptions.err; err.println("usage: jode.Obfuscator flags* [class | package]*"); err.println("\t-v "+ "Verbose output (allowed multiple times)."); diff --git a/jode/jode/swingui/Main.java b/jode/jode/swingui/Main.java index f5e4b61..a7af142 100644 --- a/jode/jode/swingui/Main.java +++ b/jode/jode/swingui/Main.java @@ -87,7 +87,7 @@ public class MainWindow rightPane.setDividerSize(4); allPane.setDividerLocation(200); allPane.setDividerSize(4); - GlobalOptions.err = new PrintStream(new AreaOutputStream(errorArea)); + GlobalOptions.err = new PrintWriter(new AreaWriter(errorArea)); } public synchronized void valueChanged(TreeSelectionEvent e) { @@ -138,19 +138,30 @@ public class MainWindow } } - public class AreaOutputStream extends OutputStream { + public class AreaWriter extends Writer { + boolean initialized = false; private JTextArea area; - public AreaOutputStream(JTextArea a) { + public AreaWriter(JTextArea a) { area = a; } - public void write(int b) throws IOException { - area.append(String.valueOf((byte)b)); + public void write(char[] b, int off, int len) throws IOException { + if (!initialized) { + area.setText(""); + initialized = true; + } +///#ifdef AWT10 +/// area.appendText(new String(b, off, len)); +///#else + area.append(new String(b, off, len)); +///#endif } - public void write(byte[] b, int off, int len) throws IOException { - area.append(new String(b, off, len)); + public void flush() { + } + + public void close() { } } @@ -173,8 +184,7 @@ public class MainWindow sourcecodeArea.setText(""); TabbedPrintWriter writer = - new TabbedPrintWriter(new AreaOutputStream(sourcecodeArea) - , imports); + new TabbedPrintWriter(new AreaWriter(sourcecodeArea), imports); imports.dumpHeader(writer); clazzAna.dumpSource(writer);