文件/byte[]数据转二进制字符串
😂 这篇文章最后更新于1795天前,您需要注意相关的内容是否还可用。
代码如下:
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); }
加鸡腿,加鸡腿,加鸡腿