Java BufferedReader Create getBufferedReader(Reader r)

Here you can find the source of getBufferedReader(Reader r)

Description

Wraps the specified reader in a buffered reader.

License

Apache License

Parameter

Parameter Description
r The reader being wrapped.

Return

The reader wrapped in a , or the original if it's already a buffered reader.

Declaration

public static Reader getBufferedReader(Reader r) 

Method Source Code


//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

import java.io.*;

public class Main {
    /**/*from w  w w .ja  v  a2 s.c  o m*/
     * Wraps the specified reader in a buffered reader.
     *
     * @param r The reader being wrapped.
     * @return The reader wrapped in a {@link BufferedReader}, or the original {@link Reader} if it's already
     *    a buffered reader.
     */
    public static Reader getBufferedReader(Reader r) {
        if (r instanceof BufferedReader || r instanceof StringReader)
            return r;
        return new BufferedReader(r);
    }
}

Related

  1. getBufferedReader(final File file)
  2. getBufferedReader(final InputStream inputstream)
  3. getBufferedReader(InputStream inputStream)
  4. getBufferedReader(InputStream inputStream, String charsetName)
  5. getBufferedReader(InputStream stream, String charset)
  6. getBufferedReader(Reader rd)
  7. getBufferedReader(String directory, String filename)
  8. getBufferedReader(String file)
  9. getBufferedReader(String filename)