Showing posts with label convert image file to byte array java. Show all posts
Showing posts with label convert image file to byte array java. Show all posts

Monday, January 7, 2013

Convert image to byte array and byte array to image file


This code will convert an image file to byte array and will write it into a binary file, and will read the binary file and converti it to image file.



import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedInputStream;
import javax.imageio.ImageIO;


public class conveter {

 /**
  * @param args
  */
 public static void main(String[] args) {
  try {
    
   byte[] imageInByte;
   BufferedImage originalImage = ImageIO.read(new File(
     "Chrysanthemum.jpg"));
 

Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...