Java FileReader Read readFile(File file)

Here you can find the source of readFile(File file)

Description

read File

License

Open Source License

Declaration

public static String readFile(File file) throws IOException 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileReader;

import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;

public class Main {
    public static String readFile(File file) throws IOException {
        Reader in = new FileReader(file);
        StringWriter out = new StringWriter();
        copy(in, out);//from  ww  w. j  av  a 2s  .c  o  m
        return out.toString();
    }

    public static void copy(Reader in, Writer out) throws IOException {
        int c = -1;
        while ((c = in.read()) != -1) {
            out.write(c);
        }
    }
}

Related

  1. readFile(File f)
  2. readFile(File f)
  3. readFile(File file)
  4. readFile(File file)
  5. readFile(File file)
  6. readFile(File file)
  7. readFile(File file)
  8. readFile(File file)
  9. readFile(File file)