33 |
|
|
34 |
import gnu.classpath.tools.IOToolkit; |
import gnu.classpath.tools.IOToolkit; |
35 |
import gnu.classpath.tools.NotifyingInputStreamReader; |
import gnu.classpath.tools.NotifyingInputStreamReader; |
36 |
|
import gnu.classpath.tools.MalformedInputListener; |
37 |
|
import gnu.classpath.tools.MalformedInputEvent; |
38 |
|
|
39 |
class IgnoredFileParseException extends ParseException |
class IgnoredFileParseException extends ParseException |
40 |
{ |
{ |
595 |
|
|
596 |
private int currentLine; |
private int currentLine; |
597 |
|
|
598 |
static char[] loadFile(File file, String encoding) |
static char[] loadFile(final File file, String encoding) |
599 |
throws IOException |
throws IOException |
600 |
{ |
{ |
601 |
InputStream in = new FileInputStream(file); |
InputStream in = new FileInputStream(file); |
602 |
|
NotifyingInputStreamReader notifyingInput |
603 |
|
= new NotifyingInputStreamReader(in, encoding); |
604 |
|
notifyingInput.addMalformedInputListener(new MalformedInputListener() { |
605 |
|
public void malformedInputEncountered(MalformedInputEvent event) { |
606 |
|
Main.getRootDoc().printWarning("Illegal character in file " + file + ", line " + event.getLineNumber() + ", column " + event.getColumnNumber()); |
607 |
|
try { |
608 |
|
Main.getRootDoc().printWarning(IOToolkit.getLineFromFile(file, event.getLineNumber())); |
609 |
|
Main.getRootDoc().printWarning(IOToolkit.getColumnDisplayLine(event.getColumnNumber())); |
610 |
|
} |
611 |
|
catch (IOException ignore) { |
612 |
|
} |
613 |
|
} |
614 |
|
}); |
615 |
Reader reader |
Reader reader |
616 |
= new BufferedReader(new NotifyingInputStreamReader(in, encoding)); |
= new BufferedReader(notifyingInput); |
617 |
char[] result = IOToolkit.readFully(reader); |
char[] result = IOToolkit.readFully(reader); |
618 |
reader.close(); |
reader.close(); |
619 |
return result; |
return result; |