Returns a string from the specified file.

@param file the file
@param encoding the encoding
@return the reader instance
@throws IOException if an error occurred when reading resources using any I/O operations
506411
public static String read(File file, String encoding) throws IOException {
        Reader reader = getReader(file, encoding);
        String source;
        try {
            source = read(reader);
        } finally {
            reader.close();
        }
        return source;
    }
285866
public Result<String> extractRawText(File file) throws IOException {
        return new InternalDocumentConverter(options).extractRawText(file).toResult();
    }
718917
public static Reader reader(File file) {
        E.illegalArgumentIfNot(file.canRead(), "file not readable: " + file.getPath());
        try {
            return new FileReader(file);
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
614099
public static String readTextFile(File file) throws IOException
    {
        //create reader to file (with default encoding)
        InputStream inputStream=new FileInputStream(file);
        Reader reader=IOHelper.createReader(inputStream,null);

        //read text
        String text=IOHelper.readTextStream(reader);
        
        return text;
    }
1153500
public static BufferedReader newReader(File file) throws IOException {
        CharsetToolkit toolkit = new CharsetToolkit(file);
        return toolkit.getReader();
    }
666146
public static String readCharacters(
                    final File file
                    )
    throws IOException
    {
        Reader  reader = new BufferedReader( new InputStreamReader(
                        new FileInputStream( file ), Charset.forName( "UTF-8" ) ) );
        // Note:
        // The character set should be specified to parse XML
        // containing Japanese characters.

        StringWriter  sw = new StringWriter();
        Writer  writer = new BufferedWriter( sw );

        copy( reader, writer );

        String  characters = sw.toString();

        return characters;
    }
1162716
public static String readFileToString(File file, Charset charset) throws IOException {
    InputStream in = null;
    try {
      in = new FileInputStream(file);
      StringBuilderWriter sw = new StringBuilderWriter();

      if (null == charset) IOs.copy(new InputStreamReader(in), sw);
      else IOs.copy(new InputStreamReader(in, charset.name()), sw);

      return sw.toString();
    } finally {
      IOs.close(in);
    }
  }
1207236
public static String readContent( File file ) throws IOException
    {
        Reader input = null;
        try
        {
            input = new FileReader( file );
            return readContent( input );
        }
        finally
        {
            closeQuietly( input );
        }
    }
187730
public static byte[] readFile(File file) throws IOException
    {
        //create stream to file
        InputStream inputStream=new FileInputStream(file);

        //read data
        byte[] data=IOHelper.readStream(inputStream);

        return data;
    }
1352447
public static byte[] readFileAtOnce(final File file) throws IOException {
		final FileInputStream fIn = new FileInputStream(file);
		return readFileAtOnce(fIn);
	}
182719
public static String file(File file) throws IOException {
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            return stream(in, file.length());
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
913592
public static List<String> linesFromFile(String filename,String encoding) {
    try {
      List<String> lines = new ArrayList<String>();
      BufferedReader in = new BufferedReader(new EncodingFileReader(filename,encoding));
      String line;
      while ((line = in.readLine()) != null) {
        lines.add(line);
      }
      in.close();
      return lines;
    }
    catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
465554
public static String read(URL url, String encoding) throws IOException {
        Reader reader = getReader(url, encoding);
        String source;
        try {
            source = read(reader);
        } finally {
            reader.close();
        }
        return source;
    }
288595
protected static String read(Reader file) throws IOException {
		final StringBuilder content = new StringBuilder();
		try (BufferedReader reader = new BufferedReader(file)) {
			String line = reader.readLine();
			boolean first = true;
			while (line != null) {
				if (first) {
					first = false;
				} else {
					content.append("\n"); //$NON-NLS-1$
				}
				content.append(line);
				line = reader.readLine();
			}
		}
		return content.toString();
	}
1032000
public static String readFileBufferedAsString(final File file, final String charset) throws IOException {
		return readInputStreamBufferedAsString(new FileInputStream(file), charset);
	}
39873
public InputStreamReader getFileStream(File file, String encoding)
			throws NoSuchPathException, UnmarshalException{
		try {
			return new InputStreamReader(new FileInputStream(file), encoding);
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		} catch (UnsupportedEncodingException e){
			throw new UnmarshalException(e);
		}
	}
736007
private static InputStream getFileAsInputStream(String file) throws InitializationException {
		if (file == null) {
			throw new NullPointerException("File is null");
		}
		try {
			return new FileInputStream(new File(file));
		} catch (FileNotFoundException e) {
			throw new InitializationException("File not found: " + file);
		}
	}