Java FileInputStream Read readFileToBinary(File lessCSS)

Here you can find the source of readFileToBinary(File lessCSS)

Description

read File To Binary

License

Open Source License

Declaration

public static byte[] readFileToBinary(File lessCSS) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

public class Main {
    public static byte[] readFileToBinary(File lessCSS) throws IOException {
        byte[] result;
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        FileInputStream input = new FileInputStream(lessCSS);
        try {// w  w  w.  jav a 2  s.  c  o m
            byte[] buffer = new byte[1024];
            int bytesRead = -1;
            while ((bytesRead = input.read(buffer)) != -1) {
                byteStream.write(buffer, 0, bytesRead);
            }
            result = byteStream.toByteArray();
        } finally {
            byteStream.close();
            input.close();
        }
        return result;
    }
}

Related

  1. readFileEndAsString(File file, int size_limit)
  2. readFileEx(String... file)
  3. readFileFully(File file)
  4. readFileInByteArray(String aFileName)
  5. readFileRaw(File file)
  6. readFileToByteArray(File file)
  7. readFileToByteArray(File file)
  8. readFileToByteArray(File file)
  9. readFileToByteArray(String file)