我有一个字符串,我将其转换为 bytes[] 然后我将其编码为图像,但问题是它没有将其创建回图像
BufferedReader reader2 = new BufferedReader(new FileReader("e:\\imageinString.txt"));
String buffer, lined = "";
while ((buffer = reader2.readLine()) != null) {
lined = lined + buffer;
}
byte[] byteArray = lined.getBytes("UTF-16");
InputStream in = new ByteArrayInputStream(byteArray);
BufferedImage bImageFromConvert = ImageIO.read(in);
ImageIO.write(bImageFromConvert, "bmp", new File("e:\\ppp.bmp"));
reader2.close();
我收到此错误,但我在控制台上收到此错误
Exception in thread "main" java.lang.IllegalArgumentException: image == null!
at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:925)
at javax.imageio.ImageIO.getWriter(ImageIO.java:1591)
at javax.imageio.ImageIO.write(ImageIO.java:1520)
at imagereading.Imagereading.main(Imagereading.java:47)