Java BufferedReader Read readFile(Reader reader)

Here you can find the source of readFile(Reader reader)

Description

read File

License

Open Source License

Declaration

private static String readFile(Reader reader) throws IOException 

Method Source Code

//package com.java2s;
/*/*from   www .java  2  s .  c  o  m*/
 * Copyright (c) 2016 VMware, Inc. All Rights Reserved.
 *
 * This product is licensed to you under the Apache License, Version 2.0 (the "License").
 * You may not use this product except in compliance with the License.
 *
 * This product may include a number of subcomponents with separate copyright notices
 * and license terms. Your use of these subcomponents is subject to the terms and
 * conditions of the subcomponent's license, as noted in the LICENSE file.
 */

import java.io.BufferedReader;

import java.io.IOException;

import java.io.Reader;

public class Main {
    private static String readFile(Reader reader) throws IOException {
        BufferedReader br = new BufferedReader(reader);
        StringBuilder sb = new StringBuilder();
        String read = br.readLine();
        String newLine = System.getProperty("line.separator");
        while (read != null) {
            sb.append(read);
            sb.append(newLine);
            read = br.readLine();
        }
        return sb.toString();
    }
}

Related

  1. readFile(final String filePath)
  2. readFile(final String name)
  3. readFile(final String path)
  4. readFile(final String pFile)
  5. readFile(List fieldNames, String filename)
  6. readFile(String absoluteFilePath)
  7. readFile(String aFileName)
  8. readFile(String directory)
  9. readFile(String directory, String fileName)