help ,ImageIO

Hi, I'm dynamiclly creating image files through screenshot utility of java(prog name:- and saving
them in memory sequentially(pic0.jpg,pic1.jpg....etc).Simultaneously I'm accessing the saved files from another
independent application(Prog name:- through piping(executing the application like this "Java
Test_ScreenShot|Java Test_Main").The application is in infinite loop.I'm using Version JDK 1.5
I use java ImageIO to read and write image:- My application was running well for days.But now I'm getting sudden exceptions. I got an excepton while trying to save an dynamically generated image file in the local memory using the ImageIO
class.In brief I'm getting exactly 3 types of exceptions:-
1) pic5.jpg (Access is denied) 2)"Exception in thread "main" java.lang.NullPointerException 3)Exception in thread "main" com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0xff 0xd9
Here is the code snippent I wrote:
/* Robot robot = new Robot(); BufferedImage image = robot.createScreenCapture(screenRect); // save captured image to jpg file ImageIO.write(image, "jpg", new File(outFileName));*/
And here is the exception I am finding (I never found this before, I executed the code many times ) ====================================================================================================================1)Exception Type 1:- pic5.jpg (Access is denied) at Method) at<init>( at<init>( at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance( at javax.imageio.ImageIO.createImageOutputStream( at javax.imageio.ImageIO.write( at Test_ScreenShot.main( at Test_Main.main( at Test_ScreenShot.main(
2)Exception Type 2:- "Exception in thread "main" java.lang.NullPointerException at Picture.width( at Test_Edge_Detector.not_main( at Test_Main.main("
===========================================================================================Now I tried the following as alternative of ImageIO(from jdk 1.2) to read image:- FileInputStream fis = new FileInputStream(file); JPEGImageDecoder jpeg = JPEGCodec.createJPEGDecoder(fis); jpeg.decodeAsBufferedImage(); fis.close(); But after running a long time suddenly its giving following exceptions:-
============================================================================================ Exception Type 3:- )
Exception in thread "main" com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0xff 0xd9 at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method) at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(Unknown Source)
Exception Type 4:- )
javax.imageio.IIOException: Not a JPEG file: starts with 0xff 0xd9 at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(Unknown Source) at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(Unknown Source) at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(Unknown Source) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(Unknown Source) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source) at Source) at Source) at Source) at Picture.<init>( at Test_Edge_Detector.not_main( at Test_Main.main( Exception in thread "main" java.lang.RuntimeException: Could not open file: pic45.jpg at Picture.<init>( at Test_Edge_Detector.not_main( at Test_Main.main(
My question is:- 1)Where is the actual problem?Is it any kind of bug? 2)I'm using the concept of piping recently to execute the application.Can it be the cause?
    When I googled I found the following informations.There is a bug in ImageIO while trying to write image file.But I'm not sure about that it will be relevent here :- 1)from sun's bug database:-
2)from SUN Developer Forums
3)from Java.NET forum(here they r getting the bug while they r using createScreenCapture() method of robot class,I am
also using that in my code) 3247
4)from SUN's archieve 83
5)Here is the actual implemetation of ImageIO class.I'm getting error at 391 no. line.
Thanks And Regards Subhadip
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.