Initial commit of newLISP.
[newlisp.git] / guiserver / java / FilterFileReader.java
blob01c08ed0392a75e7ddfce8a94d62d3ce636a6c60
1 //
2 // FilterFileReader.java
3 // guiserver
4 //
5 // Created by Lutz Mueller on 7/17/07.
7 import java.awt.event.*;
8 import java.io.*;
9 import java.io.InputStreamReader;
10 // import java.io.FileReader;
11 import java.io.FileInputStream;
14 public class FilterFileReader extends InputStreamReader {
16 public FilterFileReader(String path, String charSet) throws java.io.FileNotFoundException, UnsupportedEncodingException
18 super(new FileInputStream(path), charSet);
21 public FilterFileReader(String path) throws java.io.FileNotFoundException, UnsupportedEncodingException
23 super(new FileInputStream(path));
27 public class FilterFileReader extends FileReader {
29 public FilterFileReader(String path) throws java.io.FileNotFoundException
31 super(path);
35 public int read() throws java.io.IOException
37 int chr = super.read();
39 if(chr == 13)
40 chr = super.read();
42 return(chr);
45 public int read(char[] cbuf, int offset, int length) throws IOException
47 int chr;
48 int len = 0;
50 //System.out.println("reading:" + offset + " " + length);
52 for(int i = 0; i < length; i++)
54 chr = super.read();
56 if(chr == 13)
57 chr = super.read();
59 if(chr == -1) break;
61 cbuf[offset + i] = (char)chr;
62 ++len;
65 if(len == 0) return(-1);
67 return(len);