开发者

How do i use the scanner method to recreate a picture

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜