Here you can find the source of readFile(IFile file)
public static String readFile(IFile file) throws CoreException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; public class Main { public static String readFile(IFile file) throws CoreException { InputStream inputStream = file.getContents(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder sb = new StringBuilder(); try {/*from w w w . java2s.com*/ char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { sb.append(buf, 0, numRead); } } catch (IOException e) { return null; } finally { try { if (reader != null) { reader.close(); } if (inputStream != null) { inputStream.close(); } } catch (IOException e) { // Nothing } } return sb.toString(); } }