Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Java Applet, writing image file to disk from byte[]

Java Applet, writing image file to disk from byte[]

Scheduled Pinned Locked Moved Java
helpjavadata-structuresquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ptr_Electron
    wrote on last edited by
    #1

    Hi .. I am new to Java.. I will be getting image Byte array via CORBA.. In the Java Applet I should get the image data and write on to disk in Jpg format. I am trying with below code. but ImageIO.read() fails, no clue why? Could you please advise I AccessController.doPrivileged(new PrivilegedAction() to make to that I has write access and tested writing text file, file is getting created. But the issue was image is not getting created from byte array Pleaes help I just want to create image of any format from m_imgData[] and save it to disk. Thanks in advance !!

    			        			        	InputStream bteArrayInputStream = new ByteArrayInputStream(m\_imgData);
    			 				        	   final BufferedImage bufferedImage = ImageIO.read(bteArrayInputStream);
    			 				               ImageIO.write(bufferedImage, "jpg", new File("c:\\\\temp\\\\myImg.jpg"));
    
    L 1 Reply Last reply
    0
    • P ptr_Electron

      Hi .. I am new to Java.. I will be getting image Byte array via CORBA.. In the Java Applet I should get the image data and write on to disk in Jpg format. I am trying with below code. but ImageIO.read() fails, no clue why? Could you please advise I AccessController.doPrivileged(new PrivilegedAction() to make to that I has write access and tested writing text file, file is getting created. But the issue was image is not getting created from byte array Pleaes help I just want to create image of any format from m_imgData[] and save it to disk. Thanks in advance !!

      			        			        	InputStream bteArrayInputStream = new ByteArrayInputStream(m\_imgData);
      			 				        	   final BufferedImage bufferedImage = ImageIO.read(bteArrayInputStream);
      			 				               ImageIO.write(bufferedImage, "jpg", new File("c:\\\\temp\\\\myImg.jpg"));
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Check the status of the read from the stream to see why it fails. I don't think anyone here would be able to guess.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups