Here you can find the source of getReaderForFile(IFile file)
private static InputStreamReader getReaderForFile(IFile file) throws CoreException, UnsupportedEncodingException
//package com.java2s; /******************************************************************************* * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*ww w . j av a 2s.co m*/ * Contributors: * Institute for Software - initial API and implementation ******************************************************************************/ import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; public class Main { private static InputStreamReader getReaderForFile(IFile file) throws CoreException, UnsupportedEncodingException { InputStream contents = file.getContents(); InputStreamReader r = new InputStreamReader(contents, file.getCharset()); return r; } }