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);
精彩评论