Demos and Usage of java.io.Reader.close()


   1:   {
   2:     Reader fr = null;
   3:     try
   4:         ...
   5:       if ( fr != null )
   6:         try { fr.close(); } catch ( IOException e ) { e.printStackTrace(); }
   7:     }
   8:   }
   9: }

View Full Code Here
   1: 
   2:     Reader in = theClob.getCharacterStream();
   3: 
   4:         ...
   5:     theParser.parse(in);
   6:     in.close();
   7: 
   8:     return theParser.getDocument();

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.Reader;
   3: 
   4:         ...
   5: public class IOCloser {
   6:     public static void perform(Reader reader, InputStream stream) {
   7:         try {
   8:         ...
   9:         if (reader != null) {
  10:             reader.close();
  11:             return;
  12:         ...
  13:         if (stream != null) {
  14:             stream.close();

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.Reader;
   3: import java.io.StringReader;
   4:         ...
   5: 
   6:         private Reader reader;
   7: 
   8:         ...
   9:         public void close() throws IOException {
  10:             reader.close();
  11:         }

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.Reader;
   3: import java.io.StringWriter;
   4:         ...
   5: 
   6:     private Reader getReader(String resource) {
   7:         return new InputStreamReader(this.getClass().getClassLoader()
   8:         ...
   9: 
  10:     protected String read(Reader in) throws IOException {
  11:         BufferedReader br = new BufferedReader(in);
  12:         ...
  13:         }
  14:         in.close();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.Reader;
   3: import java.nio.channels.ClosedChannelException;
   4:         ...
   5:   
   6:   protected Reader in;
   7:   
   8:         ...
   9:   protected FilterXReader(Reader in)
  10:   {
  11:         ...
  12:       closeInstance();
  13:       in.close();

View Full Code Here
   1: 
   2:     protected static Object getText(Reader reader, boolean needToClose)
   3:         throws IOException
   4:         ...
   5:         {
   6:             return getText(reader, -1, needToClose);
   7:         }
   8:         ...
   9:                 if (needToClose){
  10:                     reader.close();
  11:                 }

View Full Code Here
   1:       long start = System.currentTimeMillis();
   2:       Reader reader = new FileReader(args[0]);
   3:       Writer writer = new FileWriter(args[1]);
   4:         ...
   5:       int c;
   6:       while ((c = reader.read()) != -1) {
   7:          writer.write(c);
   8:         ...
   9:       }
  10:       reader.close();
  11:         ...
  12:       writer.close();

View Full Code Here
   1:       long start = System.currentTimeMillis();
   2:       Reader reader = new BufferedReader(new FileReader(args[0]));
   3:       Writer writer = new BufferedWriter(new FileWriter(args[1]));
   4:         ...
   5:       int c;
   6:       while ((c = reader.read()) != -1) {
   7:          writer.write(c);
   8:         ...
   9:       }
  10:       reader.close();
  11:         ...
  12:       writer.close();

View Full Code Here
   1:       long start = System.currentTimeMillis();
   2:       Reader reader = new FileReader(args[0]);
   3:       Writer writer = new FileWriter(args[1]);
   4:         ...
   5:       char[] cbuf = new char[1024 * 8];
   6:       while ((length = reader.read(cbuf)) != -1) {
   7:          writer.write(cbuf, 0, length);
   8:         ...
   9:       }
  10:       reader.close();
  11:         ...
  12:       writer.close();

View Full Code Here
   1:     {
   2:         Reader r = new BufferedReader(new FileReader(name));
   3:         StreamTokenizer st = new StreamTokenizer(r);
   4:         ...
   5:         }
   6:         r.close();
   7:     }
   8: }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.Reader;
   3: 
   4:         ...
   5: public class CountLinesReader extends Reader {
   6: 
   7:         ...
   8:     private Reader inner;
   9: 
  10:         ...
  11:     public void close() throws IOException {
  12:         inner.close();

View Full Code Here
   1:       long start = System.currentTimeMillis();
   2:       Reader reader = new BufferedReader(new FileReader(args[0]));
   3:       Writer writer = new BufferedWriter(new FileWriter(args[1]));
   4:         ...
   5:       char[] cbuf = new char[1024 * 8];
   6:       while ((length = reader.read(cbuf)) != -1) {
   7:          writer.write(cbuf, 0, length);
   8:         ...
   9:       }
  10:       reader.close();
  11:         ...
  12:       writer.close();

View Full Code Here
   1:     protected LineHandler handler;
   2:     protected Reader input;
   3:     protected boolean needToClose;
   4:         ...
   5: 
   6:     public LineReader(Reader input, int sz, LineHandler handler, boolean needToClose){
   7:         super(sz);
   8:         ...
   9: 
  10:     public LineReader(Reader input, LineHandler handler, boolean needToClose){
  11:         this(input, defaultCharBufferSize, handler, needToClose);
  12:         ...
  13:             if (needToClose){
  14:                 input.close();

View Full Code Here
   1: 
   2: import java.io.Reader;
   3: import java.io.IOException;
   4:         ...
   5:   public void close() throws IOException {
   6:     input.close();
   7:   }
   8:         ...
   9: 
  10:   public void reset(Reader input) throws IOException {
  11:     this.input = input;

View Full Code Here