Help ,ImageIO exception to read and write

Hi,
I'm dynamically creating image files through screens utility of java(prog name:- Test_ScreenShot.java) and saving
them in memory sequentially(pic0.jpg,pic1.jpg....etc).Simultaneously I'm accessing the saved files from another
independent application(Prog name:- Test_Main.java) through piping(executing the application like this "Java
Test_Screens|Java Test_Main").The application is in infinite loop.I'm using Version JDK 1.5
I use java Image to read and write image:-
My application was running well for days.But now I'm getting sudden exceptions.
I got an exception while trying to save an dynamically generated image file in the local memory using the Image
class.In brief I'm getting exactly 3 types of exceptions:-
1)java.io.FileNotFoundException: 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:-
java.io.FileNotFoundException: pic5.jpg (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at javax.imageio.stream.FileImageOutputStream.<init>(FileImageOutputStream.java:44)
at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(FileImageOutputStreamSpi.java:37)
at javax.imageio.ImageIO.createImageOutputStream(ImageIO.java:391)
at javax.imageio.ImageIO.write(ImageIO.java:1483)
at Test_ScreenShot.main(Test_ScreenShot.java:112)
at Test_Main.main(Test_Main.java:466)
at Test_ScreenShot.main(Test_ScreenShot.java:129)
2)Exception Type 2:-
"Exception in thread "main" java.lang.NullPointerException
at Picture.width(Picture.java:84)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:38)
at Test_Main.main(Test_Main.java:88)"
============================================================================================
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 com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at Picture.<init>(Picture.java:22)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
at Test_Main.main(Test_Main.java:88)
Exception in thread "main" java.lang.RuntimeException: Could not open file: pic45.jpg
at Picture.<init>(Picture.java:27)
at Test_Edge_Detector.not_main(Test_Edge_Detector.java:37)
at Test_Main.main(Test_Main.java:88)
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:-
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6247985
2)from SUN Developer Forums
http://forum.java.sun.com/thread.jspa?threadID=768917&messageID=4382833
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)
http://forums.java.net/jive/thread.jspa?messageID=123247
4)from SUN's archieve
http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=java-imageio-interest&D=0&P=1483
5)Here is the actual implemetation of ImageIO class.I'm getting error at 391 no. line.
http://kickjava.com/src/javax/imageio/ImageIO.java.htm
Thanks And Regards
Subhadip

Hello,
I am writng to ask a doubt I have been encountered. I have an array of Image URL's and I am downloading the images using thses URL for each index. The example for an image URL will be as follows:
http://www.firstmonday.org/issues/issue6_10/wiggins/google-3oct2001.gifIf the URL is abroken link, I am getting the exception. But if the URL is somewhat hanging (which means when u open that URL in IE or Mozilla, the statuc bar for downloading the image will be hanging).
So i want to set a timer for every link while downloading. may be 10min. My idea is if in that 10min, if code does not completes downloading the images, then ignore that link and proceed furthur.
Can u please tell me how to write this.. Please tell me any other idea to tackle this problem.
Thank you,
Chaitanya

Similar Messages

  • HELP!: How to read and write to External hard drives? What file system to use?

    hey all, this has been really frustrating for me today. i want to be able to write to an external HDD that's formatted in NTFS. today i find out it isn't possible to write to this file system on a Mac and that on FAT32 it is possible. however, FAT32 can't address files larger than 4GB so this hurts me a lot. are there any other file systems that'll allow me to read and write from a Mac? my goal was to use freeNAS to build a NAS with an old tower and connect my external hard drives to it, but if i can't write to them this may not be possible.
    thanks guys, i'd appreciate any help!

    Read this, you don't need to install any software unless you have no choice.
    https://discussions.apple.com/docs/DOC-3044
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents

  • Help with how to read and write files to the applets server

    I am writing a form that requires some data to be written serverside(not on the host machine) and I also need to be able to read from those same files.
    Can anyone provide any help?
    I looked into signing but it seems, to me, that signing is for when you are going to be modifying files on the host...

    brianb7590 wrote:
    Would I use that to refer to the file like I would with a regular application?Nope. It's pretty complicated. You've got to set something up on the server to accept requests, get all the data and then save files somewhere and on the client side you've got to make the connection and send the data.
    Edited by: tjacobs01 on Apr 13, 2009 5:49 PM

  • How read and write file

    Hi
    please help me
    How to read and write data from file in j2me

    hello, u are looking to write some persistant data to a file on the mobile phone? Its the next step for me aswell. You can use the recordset function.
    I'm looking at this site: http://www-128.ibm.com/developerworks/library/wi-rms/
    It seems every time you use the function you must use try catch blocks. I hope this is what you are looking for.

  • Need help to read and write using UTF-16LE

    Hello,
    I am in need of yr help.
    In my application i am using UTF-16LE to export and import the data when i am doing immediate.
    And sometimes i need to do the import in an scheduled formate..i.e the export and imort will happend in the specified time.
    But in my application when i am doing scheduled import, they used the URL class to build the URL for that file and copy the data to one temp file to do the event later.
    The importing file is in UTF-16LE formate and i need to write the code for that encoding formate.
    The problem is when i am doing scheduled import i need to copy the data of the file into one temp place and they doing the import.
    When copying the data from one file to the temp i cant use the UTF-16LE encoding into the URL .And if i get the path from the URl and creating the reader and writer its giving the FileNotFound exception.
    Here is the excisting code,
    protected void copyFile(String rootURL, String fileName) {
    URL url = null;
    try {
    url = new URL(rootURL);
    } catch(java.net.MalformedURLException ex) {
    if(url != null) {
    BufferedWriter out = null;
    BufferedReader in = null;
    try {
    out = new BufferedWriter(new FileWriter(fileName));
    in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    do {
    line = in.readLine();
    if(line != null) {
    out.write(line, 0, line.length());
    out.newLine();
    } while(line != null);
    in.close();
    out.close();
    } catch(Exception ex) {
    Here String rootURL is the real file name from where i have to get the data and its UTF-16LE formate.And String fileName is the tem filename and it logical one.
    I think i tried to describe the problem.
    Plz anyone help me.
    Thanks in advance.

    Hello,
    thanks for yr reply...
    I did the as per yr words using StreamWriter but the problem is i need a temp file name to create writer to write into that.
    but its an logical one and its not in real so if i create Streamwriten in that its through FileNotFound exception.
    The only problem is the existing code build using URL and i can change all the lines and its very difficult because its vast amount of data.
    Is anyother way to solve this issue?
    Once again thanks..

  • I have an external hard drive, from Iomega. However, I cannot copy or save any file to it. On my PC it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?

    I have an external hard drive, from Iomega. that I can open and see my files. However, I cannot copy or save any file to it. On my PC I have it says that is possible to read and write in it, but in my Mac, it says I can only read. can somebody help me?
    Also, Im a photographer, so I like to name a lot of files at the same time (used to do in on PC and it was very usefull.) cannot find out how to do it on my Mac. Really appretiate if some one can give me a solution! Thanx

    Your drive is formatted with the NTFS file system.  OS X can read but not write to the NTFS file system.  There are third party drivers available that claim to add the ability to OS X to write to an NTFS partition.  I have not tried them and don't know if they work.
    The only file system that OS X and Windows can both write to natively is the FAT32 file system.

  • Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Snow Lepard it work just perfectly... help please.

    Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Snow lepard it work just perfectly... help please.

    Reinstall MacFuse with the one from http://www.tuxera.com/mac/macfuse-core-10.5-2.1.9.dmg. If that doesn't work, you can use Paragon NTFS for Mac 9.0 which has been designed to work with Lion.

  • Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Lion it work just perfectly... help please.

    Just bought a mac air with OS X v.10.7 Lion, for work I need to read and write NTFS drives, I install MacFuse and NTFS-3G, but it can not mount (recognize?) External HDD, in my MBP with Lion it work just perfectly... help please.

    Sorry in my MBP Snow lepard it work.. don't have Lion In MBP

  • I cannot update from OS 10.9.4 to 10.9.5. I get a message saying: File couldn't be installed error (513). I have configured my OS so that I have read and write permission followed by system with read and writ permission. Can someone help me? Thanks.

    I cannot update from OS X 10.9.4 t0 10.9.5> Whenever I try I get the following message: File couldn't be installed error (513) and something about not having the proper permission.  Under the Macintosh HD sharing and permissions settings I have customized the settings so that (Me) has read and write permission followed by the system with read and write permission, wheel and everyone have Read permissions.
    I have no problems updating apps such as Adobe CC or iTunes but cannot update the operating system, can someone help me? Thanks.

    1. Restart the computer in safe mode. Certain caches maintained by the system will be rebuilt.
    Safe mode is much slower to start up than normal. The next normal startup may also be somewhat slow.
    When the login screen appears, restart as usual (not in safe mode) and test. There's no need to log in while in safe mode.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, go to Step 2.
    If there's no change after taking this step, continue.
    2. Back up all data before proceeding.
    Triple-click anywhere in the line below on this page to select it:
    /var/folders
    Right-click or control-click the highlighted line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "folders" selected. Move the selected item to the Trash. You may be prompted for your administrator login password. Restart the computer and empty the Trash.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

  • Help ... 8530 .. Language..​. Want .. Add ... Read and Write Chinese Japan English Language

    Helooo I Want Download Link and ... Solution How To Add Input language More ..
    Read and Write... in Chinese japan english language in my blackberry 8530 curve.. Os 5.0.0. Bundle... 1675.....
    Thank  You......................................
    Solved!
    Go to Solution.

    Hi and Welcome to the Community!
    Please start with these KBs:
    KB05305Localization support for BlackBerry smartphones
    KB17208 How to install and configure the East Asian language pack on a BlackBerry smartphone
    If you get stuck somewhere, please be very explicit (the exact KB, the exact step, etc.) when you come back to ask more.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I'm trying to share folder between users on a single mac.  I put the folder in "shared," set permissions so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    I'm trying to share a folder between users on a single mac.  I want both users to be able to read and write so the folder stays current on both accounts.  I put the folder in "shared," set permissions on folder so other user can read and write, enabled file sharing, but can't find the folder on the second user's account.  Any help?

    Did you log out of one account and into the other or just used Fast user switching?
    Is the permissions set to anyone?
    When you move data to teh Shared folder is it copied or just moved?
    If copied then it's not a folder both can access, just a way station like a USB thumb drive that things are coped too and off of likely.
    You can run this #5 on each user account to reset the user permissions once they are taken back out of the Shared folder
    Step by Step to fix your Mac

  • Help.  After updating my software my external disc is "read" only.  How do I change this back to read and write?, help.  After updating my software my external disc is "read" only.  How do I change this back to read and write?

    Help.  After updating my software my external disc is "read" only.  How do I change it back to Read and Write?
    Thanks

    Have you formatted it for Mac using Disk Utility?
    If not, open Disk Utility (Applications>Utilities folder) and select the drive to the left. Make sure that you select "Mac OS Extended (Journaled)" and then the erase button.
    If you have already formatted the drive, call back...
    Clinton

  • I have the latest Mac Air 13" and I have a Seagate 500MB external hard disk I cant copy or Cut any files on the hard disk and I cant even delete any files. I have the settings as Read and Write in the get info tab. Please help

    I have the latest Mac Air 13" and I have a Seagate 500MB external hard disk I cant copy or Cut any files on the hard disk and I cant even delete any files. I have the settings as Read and Write in the get info tab. Please helpand also note that my hard drive was formatted on a Windows 7 Laptop.

    thats the problem, its in MSDos (Fat) or NTFS for Windows.
    Options.....
    1. offload all that data on the HD onto your PC, THEN format the HD in EXFAT for use on BOTH PC and Mac for read/write.....then reload all (or as you need) that data back onto the HD
    2. get another HD, and format it for Mac OSX extended journaled.
    FAT32 (File Allocation Table)
    Read/Write FAT32 from both native Windows and native Mac OS X.
    Maximum file size: 4GB.
    Maximum volume size: 2TB
    You can use this format if you share the drive between Mac OS X and Windows computers and have no files larger than 4GB.
    NTFS (Windows NT File System)
    Read/Write NTFS from native Windows.
    Read only NTFS from native Mac OS X
    To Read/Write/Format NTFS from Mac OS X, here are some alternatives:
    For Mac OS X 10.4 or later (32 or 64-bit), install Paragon (approx $20) (Best Choice for Lion)
    Native NTFS support can be enabled in Snow Leopard and Lion, but is not advisable, due to instability.
    AirPort Extreme (802.11n) and Time Capsule do not support NTFS
    Maximum file size: 16 TB
    Maximum volume size: 256TB
    You can use this format if you routinely share a drive with multiple Windows systems.
    HFS+     ((((MAC FORMAT)))  (Hierarchical File System, a.k.a. Mac OS Extended (Journaled) Don't use case-sensitive)
    Read/Write HFS+ from native Mac OS X
    Required for Time Machine or Carbon Copy Cloner or SuperDuper! backups of Mac internal hard drive.
    To Read HFS+ (but not Write) from Windows, Install HFSExplorer
    Maximum file size: 8EiB
    Maximum volume size: 8EiB
    You can use this format if you only use the drive with Mac OS X, or use it for backups of your Mac OS X internal drive, or if you only share it with one Windows PC (with MacDrive installed on the PC)
    EXFAT (FAT64)    ------Can read/write from both PC and Mac
    Supported in Mac OS X only in 10.6.5 or later.
    Not all Windows versions support exFAT. 
    exFAT (Extended File Allocation Table)
    AirPort Extreme (802.11n) and Time Capsule do not support exFAT
    Maximum file size: 16 EiB
    Maximum volume size: 64 ZiB
    You can use this format if it is supported by all computers with which you intend to share the drive.  See "disadvantages" for details.

  • Urgent: Please help. how to solve the time delay during buffer read and write using vc++

    I need to continuously acquire data from daqmx card, write into a file and at the same time corelate (in terms of time) the data with signals from other instruments. The current problem is that there is time delay during read and write data into buffer,thus causing misalignment of the data from multiple instruments. Is there a way to solve  the delay? or Is there a way to mark the time of the data acquisition in the buffer?  If I know the starting time (e.g. 0) of data acquisition and sampling rate (e.g. 1kHz), can I simply add 1ms to each data sample in the buffer? The current code is shown below.
    void DataCollectionWin::ConnectDAQ()
    DAQmxErrChk(DAQmxCreateTask ("", &taskHandle));
        DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
      DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));
      DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,50,0,EveryNCallback,NULL));// Every 50 samples the EveryNSamplesEvent will be trigured, to reduce time delay.
      DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
      DAQmxErrChk (DAQmxStartTask(taskHandle));
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
     DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,NULL));
       //memcpy(l_data,data,6000);
      SetEvent(hEvent);
    l_usstatus_e[0]=g_usstatus[0];// signals from other instruments that need to be corelated with the data from daq cards.
     l_optstatus_e[0]=g_optstatus[0];
     if( read>0 ) // write data into file
       //indicator=1;
     for (i=0;i<read;i++)
     {  //fprintf(datafile,"%d\t",i);
      fprintf(datafile,"%c\t",l_usstatus_s[0]);
      fprintf(datafile,"%c\t",l_usstatus_e[0]);
            fprintf(datafile,"%c\t",l_optstatus_s[0]);
      fprintf(datafile,"%c\t",l_optstatus_e[0]);
              fprintf(datafile,"%.2f\t",data[15*i]);
     //   sprintf( pszTemp, "%f", data[6*i]);
     // pListCtrl->SetItemText(0, 2, pszTemp);
        //pWnd->m_trackinglist.SetItemText(0, 2, pszTemp);
         fprintf(datafile,"%.2f\t",data[15*i+1]);
         fprintf(datafile,"%.2f\t",data[15*i+2]);

    Hello kgy,
    It is a bit of a judgment call. You should just choose the board that you think has the most to do with your issue. For example, this issue was much more focused on setting up your data acquisition task than the Measurement Studio environment/tools, so the MultifunctionDAQ board would have been the best place for it. As for moving your post to another board, I do not believe that is possible.
    Regards,
    Dan King

Maybe you are looking for