I have a file in Java
FileInputStream in = null;
try{
in = new FileInputStream(\"C:\\\\pic.bmp\");
}catch{}
I want to convert pic.b
Java has an extensive image reading/writing and editing library. Look at the javax.imageio
packages (here's the documentation). You would probably want to create a BufferedImage
using ImageIO
and then access the image data from the BufferedImage
object (there are methods for that).
If you want a generic answer, for any type of binary data (not just images), then I guess you would have to read the contents of the file into a byte array. Something like this:
byte[] bytes = new byte[in.available()];
in.read(bytes);