代码如下:
public static void main(String[] args) throws IOException { String path = "D:/a.jpg"; File file = new File(path); FileInputStream is=new FileInputStream(file); byte[] bytes=new byte[is.available()]; StringBuilder sb = new StringBuilder(); is.read(bytes); is.close(); for (byte aByte : bytes) {// sb.append(aByte); sb.append(Integer.toBinaryString(aByte)); } System.out.println(sb); }
#cmt102