Java InputStreamReader Read readFile(IFile theFile)

Here you can find the source of readFile(IFile theFile)

Description

read File

License

Open Source License

Declaration

public static String readFile(IFile theFile) throws CoreException, IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;

public class Main {
    public static String readFile(IFile theFile) throws CoreException, IOException {
        InputStream is = theFile.getContents();
        Reader r = new InputStreamReader(is);
        StringBuilder data = new StringBuilder();
        /*/*from   w  ww  .ja  v a  2 s.c o  m*/
         * buffer size hack -- if there's a good implementation of
         * available, then we'll go through the buffer in one try
         */
        char[] buffer = new char[Math.max(1024, is.available())];
        int charsRead;
        while ((charsRead = r.read(buffer)) >= 0)
            data.append(buffer, 0, charsRead);
        return data.toString();
    }
}

Related

  1. readFile(final File file)
  2. readFile(final File inputFile)
  3. readFile(final String aFileName)
  4. readFile(final String path)
  5. readFile(IFile file)
  6. readFile(InputStream aStream)
  7. readFile(InputStream in)
  8. readFile(InputStream in)
  9. readFile(InputStream inputStream)