Here you can find the source of readFile(Reader reader)
private static String readFile(Reader reader) throws IOException
//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(); } }