package com.pritom.kumar; import java.io.File; import java.io.FileInputStream; /** * Created by pritom on 28/06/2016. */ public class ReadFileAsByteArray { public static void main (String[] args) throws Exception { File file = new File("x1.zip"); FileInputStream fileInputStream = new FileInputStream(file); byte[] toByte = new byte[(int) file.length()]; fileInputStream.read(toByte); fileInputStream.close(); System.out.println("File_Length=" + file.length() + ", Byte_Length=" + toByte.length + ", Both_Are_Equal=" + (file.length() == toByte.length ? "True" : "False")); } }
Tuesday, June 28, 2016
Java Convert File Into Bytes (Array of Bytes)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment