JTextArea problem

Hi, I have a problem whereby the JTextArea does not append the sentence "File not available" when the file by the name "myfile.pps" is not found in the "f " drive folder of the USB after i insert the USB diskdrive.

The JTextArea is required to append "File not available" when the system found there's no file "myfile.pps" in the USB folder of the user.

Can i know what's wrong with the code i did below?

publicvoid create(){

final JTextArea ta =new JTextArea(10,20);

ta.append("Searching USB disk drive\n\n");

final File f =new File("F://");

String filename ="f:\\myfile.pps";

if(f.exists()){

ta.append("Drive inserted!\n");

try{

Runtime.getRuntime().exec(new String[]{"cmd","/c","start","f:\\myfile.pps"});

}

catch (Exception x){

x.printStackTrace();

}

catch (Error r){

e.printStackTrace();

}

if(filename!="f:\\myfile.pps"){

ta.append("File not available!\n");

}

}

else{

ta.append("Detection failed!\n");

}

}

thanks alot,

jp

[2239 byte] By [juniorprogrammera] at [2007-11-27 8:18:38]
# 1

This is just a hunch, but try changing to following code

if(filename!="f:\\myfile.pps") {

ta.append("File not available!\n");

}

to

if(filename.equalsIgnoreCase("f:\\myfile.pps")) {

ta.append("File not available!\n");

}

ICE

icewalker2ga at 2007-7-12 20:06:55 > top of Java-index,Desktop,Core GUI APIs...