Reads the data from the file.

@param   file
The file
@return  The data read from the provided file
@throws  IOException
Any IO exception
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;
    }
208924
public static String file2String(File file) throws IOException {
        if (file == null || !file.exists() || !file.isFile() || !file.canRead()) {
            return null;
        }
        FileReader reader = null;
        StringWriter writer = null;
        try {
            reader = new FileReader(file);
            writer = new StringWriter();
            char[] cbuf = new char[1024];
            int len = 0;
            while ((len = reader.read(cbuf)) != -1) {
                writer.write(cbuf, 0, len);
            }
            return writer.toString();
        } finally {
            IOUtils.closeQuietly(reader);
            IOUtils.closeQuietly(writer);
        }
    }
11785
public Table file(File file) throws IOException {
	String extension = Files.getFileExtension(file.getCanonicalPath());
	DataReader<?> reader = registry.getReaderForExtension(extension);
	return reader.read(new Source(file));
    }
394468
public static Experiment readExperiment(final File file) throws IOException {
        checkNotNull(file);
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            return readExperiment(reader);
        }
    }
11128
public static List<String> readFileToLinesList( File file ) throws IOException {
        List<String> lines = new ArrayList<>();
        try (BufferedReader br = new BufferedReader(new FileReader(file))) {
            String line;
            while( (line = br.readLine()) != null ) {
                lines.add(line);
            }
            return lines;
        }
    }
949267
public static Properties load(File file) throws IOException {
        if (file.isFile()) {
            FileInputStream fis = null;
            try {
                Properties headers = new Properties();
                fis = new FileInputStream(file);
                headers.load(fis);
                return headers;
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }
        return new Properties();
    }
843106
public static String readFromFileIntoString(File file) throws IOException {
        FileInputStream inputStream = new FileInputStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
        StringBuilder text = new StringBuilder();

        String line;
        while( (line = reader.readLine()) != null) {
            text.append(line).append("\n");
        }
        inputStream.close();

        return text.toString();
    }
944199
public static List<String> readFileToList(final File file, final String encoding)
		throws IOException
	{
		final List<String> fn = new ArrayList<>();
		try (BufferedReader reader = (BufferedReader)StreamExtensions.getReader(file, encoding,
			false))
		{
			// the line.
			String line = null;
			// read all lines from the file
			do
			{

				line = reader.readLine();

				// if null break the loop
				if (line == null)
				{
					break;
				}
				fn.add(line);

			}
			while (true);
		}
		catch (final IOException e)
		{
			throw e;
		}
		return fn;
	}
1083702
public static String loadString(String file) throws IOException {
		StringBuilder sb = new StringBuilder();
		UnicodeReader reader = new UnicodeReader(new FileInputStream(file), "utf8");
		int n;	
		char[] cs = new char[256];
		while ((n = reader.read(cs)) != -1) {		
			sb.append(Arrays.copyOfRange(cs, 0, n));			
		}
		return sb.toString();
	}
743068
public static byte[] readFile(File file) throws IOException {
        // Open file
        RandomAccessFile f = new RandomAccessFile(file, "r");
        try {
            // Get and check length
            long longlength = f.length();
            int length = (int) longlength;
            if (length != longlength) {
                throw new IOException("File size >= 2 GB");
            }
            // Read file and return data
            byte[] data = new byte[length];
            f.readFully(data);
            return data;
        } finally {
            // Close file
            f.close();
        }
    }
1059961
public static RegionMetadata load
    (final File file) throws IOException {
        return RegionMetadataParser.parse(new BufferedInputStream(new
                FileInputStream(file)));
    }
14902
static String readFile(String file) {

        try {
            FileReader     reader = new FileReader(file);
            BufferedReader read   = new BufferedReader(reader);
            StringBuffer   b      = new StringBuffer();
            String         s      = null;
            int            count  = 0;

            while ((s = read.readLine()) != null) {
                count++;

                b.append(s);
                b.append('\n');
            }

            read.close();
            reader.close();

            return b.toString();
        } catch (IOException e) {
            return e.getMessage();
        }
    }
1053682
public static byte[] read(File file) throws IOException {
        FileInputStream is = new FileInputStream(file);
        try {
            return bytes(is);
        } finally {
            closeQuietly(is);
        }
    }
827243
public String read(String filename) throws IOException {
    Path p = new Path(filename);
    int size = (int) getMfs().getFileStatus(p).getLen();
    FSDataInputStream is = getMfs().open(p);
    byte[] content = new byte[size];
    is.readFully(content);
    return new String(content);
  }
557587
public static String readString(File file, Charset charset) throws IOException {
        if (file == null || !file.isFile()) {
            return null;
        }
        StringBuilder fileContent = new StringBuilder();

        BufferedReader reader = null;
        try {
            InputStreamReader is = new InputStreamReader(new FileInputStream(file), charset);
            reader = new BufferedReader(is);
            String line = null;
            while ((line = reader.readLine()) != null) {
                if (!fileContent.toString().equals("")) {
                    fileContent.append("\r\n");
                }
                fileContent.append(line);
            }
            reader.close();
            return fileContent.toString();
        } finally {
            closeQuietly(reader);
        }
    }
838833
public static String readFileFromClasspath(String file) {
		logger.trace("Reading file [{}]...", file);
		String content = null;

		try (InputStream asStream = SettingsReader.class.getClassLoader().getResourceAsStream(file)) {
			if (asStream == null) {
				logger.trace("Can not find [{}] in class loader.", file);
				return null;
			}
			content = IOUtils.toString(asStream, "UTF-8");
		} catch (IOException e) {
			logger.warn("Can not read [{}].", file);
		}

		return content;
	}
249413
public static void encode(File file) throws IOException {
        if (!file.exists()) {
            System.exit(0);
        }

        else {
            byte[] decoded = readBytes(file);
            char[] encoded = encode(decoded);
            writeChars(file, encoded);
        }
        file = null;
    }