PrintStream replaced with PrintWriter

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@920 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 5764dddd92
commit b7154b62d7
  1. 2
      jode/jode/Decompiler.java
  2. 4
      jode/jode/GlobalOptions.java
  3. 29
      jode/jode/JodeWindow.java
  4. 4
      jode/jode/obfuscator/Main.java
  5. 28
      jode/jode/swingui/Main.java

@ -55,7 +55,7 @@ public class Decompiler {
public static int outputStyle = SUN_STYLE; public static int outputStyle = SUN_STYLE;
public static void usage() { public static void usage() {
PrintStream err = GlobalOptions.err; PrintWriter err = GlobalOptions.err;
err.println("Version: " + GlobalOptions.version); err.println("Version: " + GlobalOptions.version);
err.print("use: jode [-v]" err.print("use: jode [-v]"
+"[--cp <classpath>][--dest <destdir>]" +"[--cp <classpath>][--dest <destdir>]"

@ -18,7 +18,7 @@
*/ */
package jode; package jode;
import java.io.PrintStream; import java.io.PrintWriter;
import java.util.StringTokenizer; import java.util.StringTokenizer;
public class GlobalOptions { public class GlobalOptions {
@ -29,7 +29,7 @@ public class GlobalOptions {
public final static String URL = public final static String URL =
"http://www.informatik.uni-oldenburg.de/~delwi/jode/jode.html"; "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 verboseLevel = 0;
public static int debuggingFlags = 0; public static int debuggingFlags = 0;

@ -143,7 +143,7 @@ public class JodeWindow
startButton.addActionListener(this); startButton.addActionListener(this);
saveButton.addActionListener(this); saveButton.addActionListener(this);
///#endif ///#endif
GlobalOptions.err = new PrintStream(new AreaOutputStream(errorArea)); GlobalOptions.err = new PrintWriter(new AreaWriter(errorArea));
} }
public void setClasspath(String cp) { 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; boolean initialized = false;
private TextArea area; private TextArea area;
public AreaOutputStream(TextArea a) { public AreaWriter(TextArea a) {
area = a; area = a;
} }
public void write(int b) throws IOException { public void write(char[] b, int off, int len) 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 {
if (!initialized) { if (!initialized) {
area.setText(""); area.setText("");
initialized = true; initialized = true;
@ -231,6 +219,12 @@ public class JodeWindow
area.append(new String(b, off, len)); area.append(new String(b, off, len));
///#endif ///#endif
} }
public void flush() {
}
public void close() {
}
} }
public void run() { public void run() {
@ -266,8 +260,7 @@ public class JodeWindow
} }
TabbedPrintWriter writer = TabbedPrintWriter writer =
new TabbedPrintWriter(new AreaOutputStream(sourcecodeArea) new TabbedPrintWriter(new AreaWriter(sourcecodeArea), imports);
, imports);
ClassAnalyzer clazzAna = new ClassAnalyzer(null, clazz, imports); ClassAnalyzer clazzAna = new ClassAnalyzer(null, clazz, imports);
clazzAna.dumpJavaFile(writer); clazzAna.dumpJavaFile(writer);

@ -22,7 +22,7 @@ import jode.bytecode.ClassInfo;
import jode.obfuscator.*; import jode.obfuscator.*;
import java.util.Vector; import java.util.Vector;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.io.PrintStream; import java.io.PrintWriter;
public class Obfuscator { public class Obfuscator {
public static boolean shouldStrip = true; public static boolean shouldStrip = true;
@ -42,7 +42,7 @@ public class Obfuscator {
public static final int RENAME_NONE = 3; public static final int RENAME_NONE = 3;
public static void usage() { public static void usage() {
PrintStream err = GlobalOptions.err; PrintWriter err = GlobalOptions.err;
err.println("usage: jode.Obfuscator flags* [class | package]*"); err.println("usage: jode.Obfuscator flags* [class | package]*");
err.println("\t-v "+ err.println("\t-v "+
"Verbose output (allowed multiple times)."); "Verbose output (allowed multiple times).");

@ -87,7 +87,7 @@ public class MainWindow
rightPane.setDividerSize(4); rightPane.setDividerSize(4);
allPane.setDividerLocation(200); allPane.setDividerLocation(200);
allPane.setDividerSize(4); allPane.setDividerSize(4);
GlobalOptions.err = new PrintStream(new AreaOutputStream(errorArea)); GlobalOptions.err = new PrintWriter(new AreaWriter(errorArea));
} }
public synchronized void valueChanged(TreeSelectionEvent e) { 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; private JTextArea area;
public AreaOutputStream(JTextArea a) { public AreaWriter(JTextArea a) {
area = a; area = a;
} }
public void write(int b) throws IOException { public void write(char[] b, int off, int len) throws IOException {
area.append(String.valueOf((byte)b)); 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 { public void flush() {
area.append(new String(b, off, len)); }
public void close() {
} }
} }
@ -173,8 +184,7 @@ public class MainWindow
sourcecodeArea.setText(""); sourcecodeArea.setText("");
TabbedPrintWriter writer = TabbedPrintWriter writer =
new TabbedPrintWriter(new AreaOutputStream(sourcecodeArea) new TabbedPrintWriter(new AreaWriter(sourcecodeArea), imports);
, imports);
imports.dumpHeader(writer); imports.dumpHeader(writer);
clazzAna.dumpSource(writer); clazzAna.dumpSource(writer);

Loading…
Cancel
Save