File.renameTo fails when used with MediaTracker.
// The following code fails to rename the file
String fileName ="1.jpg";
String uploadedFile =new File("c:/uploaded", fileName);
Image image = Toolkit.getDefaultToolkit().getImage(uploadedFile.toString());
MediaTracker mediaTracker =new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
// If the uploaded image is a highrespic, move it to the highres folder
if (image.getWidth(null) > MAX_FOTO_WIDTH || image.getHeight(null) > MAX_FOTO_HEIGHT){
mediaTracker.removeImage(image, 0);
image =null;
mediaTracker.waitForID(0);
File highResFile =new File("c:/highres", fileName);
if (!uploadedFile.renameTo(highResFile)){
thrownew Exception("Couldn't rename the file!");
}
}
// The following code works!
String fileName ="1.jpg";
String uploadedFile =new File("c:/uploaded", fileName);
File highResFile =new File("c:/highres", fileName);
if (!uploadedFile.renameTo(highResFile)){
thrownew Exception("Couldn't rename the file!");
}
I would like to check the height and width of the image file before moving it. Can anyone please help me figure this out!
Thanks for your help!
Joe.
Message was edited by:
Joe12
Message was edited by:
Joe12

