Search This Blog

Sunday, March 20, 2016

CONVERT FILE LOCAL TO BYTE[]

public byte[] FileLocal_To_Byte(String path){
        File file = new File(path);
        int size = (int) file.length();
        byte[] bytes = new byte[size];
        try {
            BufferedInputStream buf = new BufferedInputStream(new FileInputStream(file));
            buf.read(bytes, 0, bytes.length);
            buf.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return bytes;
}

// path
outputFile = Environment.getExternalStorageDirectory().
                getAbsolutePath() + "/filename.3gpp";

filename.3gpp nằm trong res

No comments:

Post a Comment