Java Reader Read loadChars(Reader in)

Here you can find the source of loadChars(Reader in)

Description

Load the characters contained in specified source.

License

Open Source License

Parameter

Parameter Description
in the character source

Return

the contents of the character source

Declaration

public static String loadChars(Reader in) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;

import java.io.Reader;

public class Main {
    /**/*from  www .ja  v a  2s  .com*/
     * Load the characters contained in specified source.
     * 
     * @param in the character source
     * @return the contents of the character source
     * @exception IOException if there is an I/O problem
     */
    public static String loadChars(Reader in) throws IOException {
        StringBuilder buffer = new StringBuilder();
        char[] chars = new char[65536];
        int count;

        while ((count = in.read(chars, 0, chars.length)) != -1) {
            if (count > 0) {
                buffer.append(chars, 0, count);
            }
        }

        return buffer.toString();
    }
}

Related

  1. getReaderAsString(Reader source)
  2. getReaderContentAsString(Reader reader)
  3. getReaderContents(Reader reader)
  4. load(InputStream input, int bufsize)
  5. loadFully(String path)
  6. loadReader(final Reader in, final StringBuffer buffer)
  7. loadReader(java.io.Reader in)
  8. loadResAsString(String res)