• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.io.RandomAccessFile. (Urgent please)

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have problem implementing the code which calls the file on the hard disk.
my code looks like this
BufferedImage brImg = null;
brImg = ChangeImgFormat.chg2BuffImage("images\DEFAULT_RGB24_.tif");
when my application is started for the first time, above code works fine and later i call the same code but other file
brImg = ChangeImgFormat.chg2BuffImage("images\ERROR_RGB24_.tif");
i get following error
java.io.FileNotFoundException: images\DEFAULT_RGB24_.tif (The System cant find the file specified)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:200
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:94)
at com.sun.media.jai.codec.FileSeekableStream.<init>(FileSee
java:94)
at tks.util.ChangeImgFormat.chg2BuffImage(ChangeImgFormat.ja
at tks.MainFrame.scanChannels(MainFrame.java:549)
at tks.MainFrame.startScanning(MainFrame.java:851)
at tks.MainFrame.run(MainFrame.java:251)
at java.lang.Thread.run(Thread.java:536)
please help me while iam running short of time
Thank you
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume the second file exists.
Have you tried inverting the call ,
first ->brImg = ChangeImgFormat.chg2BuffImage("images\ERROR_RGB24_.tif");
second->brImg = ChangeImgFormat.chg2BuffImage("images\DEFAULT_RGB24_.tif");
How does the ChangeImgFormat.chg2BuffImage method works. Does it make any assumption about the current directory, does it change after a call??

The exception states ( as you migth have already guessed ) that it cannot find the specified file, but the question is why...
You migth want to try to know if the file exists using
if( new File( "images\DEFAULT_RGB24_.tif" ).exists() ){}
// the file exists
}else{
// it does not.
}
if( new File( "images\ERROR_RGB24_.tif" ).exists() ){}
// the file exists
}else{
// it does not.
}
 
Nagaseshagiri poola
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you but my problem is not solved yet
try{
File imgFile = new File(picPath);
if(imgFile.exists()){resizedImage = new ChangeImgFormat().chg2BuffImage(picPath);
} else {
resizedImage = new ChangeImgFormat().chg2BuffImage("images/DEFAULT_RGB24_.tif");
}
// this method returns the modified buffered image
ChangeImgFormat().chg2BuffImage("")
so my actual problem is am saving pictures from cable TV and showing it to the Swing interface.
The picture is captured and i can see the picture on the hard drive but in the program its not able to find the picture. all the time it is saying picture doesnot exist.
i tried with the other image on other drive its working.
folder "images" is in my projects directory.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic