在没有ImageIO的情况下读写jpeg

时间:2021-09-27 21:20:54

how can i read jpeg image from byte[] and write to file? i cannot use ImageIO , Bitmap and Bitmapfactory

如何从byte []读取jpeg图像并写入文件?我不能使用ImageIO,Bitmap和Bitmapfactory

i want pure java solution , so that it works in android as well the lib i am creating is separate from android project but will be used with android and as well as desktop application so a pure java solution is needed

我想要纯java解决方案,所以它在android中工作,我正在创建的lib与android项目分开,但将与android以及桌面应用程序一起使用,因此需要纯Java解决方案

the task is simple just read byte[] and save it to a file , for that i do not want to use a lib like a openCV

任务很简单只需读取byte []并将其保存到文件中,因为我不想使用像openCV这样的lib

1 个解决方案

#1


Same as with any binary file, this should do it:

与任何二进制文件相同,这应该这样做:

try (OutputStream out = new FileOutputStream(file)) {
    out.write(bytes);
}

#1


Same as with any binary file, this should do it:

与任何二进制文件相同,这应该这样做:

try (OutputStream out = new FileOutputStream(file)) {
    out.write(bytes);
}