import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class test{
public static void main(String[] args) throws IOException {
String path = "D:/MSG_Y.GIF";
File file = new File(path);
FileInputStream fis = new FileInputStream(file);
byte[] b = new byte[fis.available()];
StringBuilder str = new StringBuilder();//不建议用String
fis.read(b);
for(byte bs:b)
{
str.append(Integer.toBinaryString(bs));//转换为二进制
}
System.out.println("==="+str);
//把字节数组的图片写到另一个地方
File apple= new File("D:/apple.jpg");
FileOutputStream fos = new FileOutputStream(apple);
fos.write(b);
fos.flush();
fos.close();
}
}