Returns the <code>byte</code>[] rawValue of the given <code>File</code>.
435182
public static byte[] getBytes(File file) throws IOException {
		InputStream in = new FileInputStream(file);
		int fileSize = (int) file.length();

		if (fileSize > Integer.MAX_VALUE) {
			in.close();
			throw new IOException("File size to large: " + fileSize + " > " + Integer.MAX_VALUE);
		}

		byte[] bytes = new byte[fileSize];

		// Read in the bytes
		int offset = 0;
		int numRead = 0;
		while (offset < bytes.length && (numRead = in.read(bytes, offset, bytes.length-offset)) >= 0) {
			offset += numRead;
		}

		// Ensure all the bytes have been read in
		if (offset < bytes.length) {
			in.close();
			throw new IOException("Could not completely read file " + file.getName());
		}

		in.close();

		return bytes;
	}
1052598
public static Byte readByte(String value, Byte defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Byte.valueOf(value);
	}
285014
static private byte[] readBinaryFile(String fileName) throws IOException {
    ByteArrayOutputStream ous = null;
    InputStream ios = null;
    try {
      byte[] buffer = new byte[4096];
      ous = new ByteArrayOutputStream();
      ios = new FileInputStream(new File(fileName));
      int read;
      while ((read = ios.read(buffer)) != -1) {
        ous.write(buffer, 0, read);
      }
    }
    finally {
      try {
        if (ous != null)
          ous.close();
      }
      catch (IOException ignore) {}

      try {
        if (ios != null)
          ios.close();
      }
      catch (IOException ignore) {}
    }
    return ous.toByteArray();
  }
1267355
private byte[] read(InputStream in) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(READ_FILE_BASE_SIZE);
		byte[] buffer = new byte[READ_BUFFER_SIZE];
		int count = in.read(buffer);
		while (count != -1) {
			if (count != 0) {
				out.write(buffer, 0, count);
			}
			count = in.read(buffer);
		}
		in.close();
		return out.toByteArray();
	}
251499
public byte[] getBytes() {
    byte[] result = new byte[2];
    result[0] = (byte) (value & BYTE_MASK);
    result[1] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT);
    return result;
  }
845513
public static String readFile(InputStream file) {
        try (BufferedInputStream stream = new BufferedInputStream(file)) {
            byte[] buff = new byte[1024];
            StringBuilder builder = new StringBuilder();
            int read;
            while ((read = stream.read(buff)) != -1) {
                builder.append(new String(buff, 0, read, StandardCharsets.UTF_8));
            }
            return builder.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1244274
private String readFileAsString(File file) throws java.io.IOException {
        StringBuilder fileData = new StringBuilder(1000);
        try (BufferedReader reader = new BufferedReader(ReaderFactory.newReader(file, this.encoding))) {
            char[] buf = new char[1024];
            int numRead = 0;
            while ((numRead = reader.read(buf)) != -1) {
                String readData = String.valueOf(buf, 0, numRead);
                fileData.append(readData);
                buf = new char[1024];
            }
        }
        return fileData.toString();
    }
1124308
@Override
    public byte[] retrieveBytes(File impFi) {
        String fname = impFi.getName();
        int idx = fname.indexOf('.');
        if ( idx >= 0 ) {
            String ext = fname.substring(idx+1).toLowerCase();
            TranspilerHook transpilerHook = transpilerMap.get(ext);
            if ( transpilerHook != null ) {
                return transpilerHook.transpile(impFi, this, new HashMap());
            }
        }
        return null;
    }
1053682
public static byte[] read(File file) throws IOException {
        FileInputStream is = new FileInputStream(file);
        try {
            return bytes(is);
        } finally {
            closeQuietly(is);
        }
    }
987566
public static byte[] toUnsignedByteArray(BigInteger value) {
		byte[] bytes = value.toByteArray();

		if (bytes[0] == 0) {
			byte[] tmp = new byte[bytes.length - 1];
			System.arraycopy(bytes, 1, tmp, 0, tmp.length);

			return tmp;
		}

		return bytes;
	}
362183
public static byte[] bytes(File file) throws IOException {
        InputStream in = null;
        try {
            in = openInputStream(file);
            return toByteArray(in, file.length());
        } finally {
            closeQuietly(in);
        }
    }
136484
public static byte[] getLocalByteArray(File res) {
		try {
			return toByteArray(new FileInputStream(res));
		} catch (FileNotFoundException e) {
			logger.error("FileNotFound", e);
		} 
		return null;
	}
406843
public int[][] fromFile(File file) throws IOException {
        BufferedImage image = ImageIO.read(file);
        image = scalingIfNeed(image, true);
        return toIntArrayArray(image);
    }
1165546
public static String getImageAsDataUri(File file) throws IOException {
        String contentType = getContentType(file);
        String base64Content = getImageAsBase64(file);

        return "data:" + contentType + ";base64," + base64Content;
    }
911541
public static byte[] md5(File file) throws IOException {
		try (InputStream in = new FileInputStream(file)) {
			return md5(in);
		}
	}
496294
public static byte[] readAsByteArray(File localSwfFile) {
        byte[] fileBytes = new byte[(int) localSwfFile.length()];
        byte[] b = new byte[1];
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(localSwfFile);
            for (int i = 0; i < Integer.MAX_VALUE; i++) {
                if (fis.read(b) != -1) {
                    fileBytes[i] = b[0];
                } else {
                    break;
                }
            }
        } catch (IOException e) {
            log.warn("Exception reading file bytes", e);
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                }
            }
        }
        return fileBytes;
    }
310881
public static byte[] getBytes(InputStream is) throws IOException {
        ByteArrayOutputStream answer = new ByteArrayOutputStream();
        // reading the content of the file within a byte buffer
        byte[] byteBuffer = new byte[8192];
        int nbByteRead /* = 0*/;
        try {
            while ((nbByteRead = is.read(byteBuffer)) != -1) {
                // appends buffer
                answer.write(byteBuffer, 0, nbByteRead);
            }
        } finally {
            closeWithWarning(is);
        }
        return answer.toByteArray();
    }