开发者

How do i use the scanner method to recreate a picture

开发者 https://www.devze.com 2023-01-29 19:16 出处:网络
I have to use scanner (in my PicturReader.java class) to recreate a picture from my PictureWriter.java class. Can anyone help me out 开发者_运维知识库i know this is a simple problem but im lostYou can

I have to use scanner (in my PicturReader.java class) to recreate a picture from my PictureWriter.java class. Can anyone help me out 开发者_运维知识库i know this is a simple problem but im lost


You can't really use the Scanner class because it's meant to read in primitive types. I don't know how you are saving the image, but it's in a file then you need to read the bytes back.

RandomAccessFile file = new RandomAccessFile("filename.jpg","r");
byte[] bytes = new byte[(int)file.length()]; //Omitted a check if the file is longer than an int
file.readFully(bytes);
0

精彩评论

暂无评论...
验证码 换一张
取 消