|
|
@ -143,6 +143,7 @@ public class Main |
|
|
|
|
|
|
|
|
|
|
|
public class AreaWriter extends Writer { |
|
|
|
public class AreaWriter extends Writer { |
|
|
|
boolean initialized = false; |
|
|
|
boolean initialized = false; |
|
|
|
|
|
|
|
boolean lastCR = false; |
|
|
|
private JTextArea area; |
|
|
|
private JTextArea area; |
|
|
|
|
|
|
|
|
|
|
|
public AreaWriter(JTextArea a) { |
|
|
|
public AreaWriter(JTextArea a) { |
|
|
@ -155,7 +156,23 @@ public class Main |
|
|
|
area.setText(""); |
|
|
|
area.setText(""); |
|
|
|
initialized = true; |
|
|
|
initialized = true; |
|
|
|
} |
|
|
|
} |
|
|
|
area.append(new String(b, off, len)); |
|
|
|
String str = new String(b, off, len); |
|
|
|
|
|
|
|
StringBuffer sb = new StringBuffer(len); |
|
|
|
|
|
|
|
while (str != null && str.length() > 0) { |
|
|
|
|
|
|
|
if (lastCR && str.charAt(0) == '\n') |
|
|
|
|
|
|
|
str = str.substring(1); |
|
|
|
|
|
|
|
int crIndex = str.indexOf('\r'); |
|
|
|
|
|
|
|
if (crIndex >= 0) { |
|
|
|
|
|
|
|
sb.append(str.substring(0, crIndex)); |
|
|
|
|
|
|
|
sb.append("\n"); |
|
|
|
|
|
|
|
str = str.substring(crIndex+1); |
|
|
|
|
|
|
|
lastCR = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sb.append(str); |
|
|
|
|
|
|
|
str = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
area.append(sb.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void flush() { |
|
|
|
public void flush() { |
|
|
|