我試圖找回在特定文件夾中的所有圖像,對於我創建了一個矢量並移動圖像到矢量,我使用的代碼是問題與加載圖像
imageNameVector.removeAllElements();
try {
FileConnection fc = (FileConnection)Connector.open("file:///e:/Images", Connector.READ_WRITE);
if(!fc.exists())
{
fc.mkdir();
}
Enumeration filelist = fc.list("*.jpg", true);
String filename;
while(filelist.hasMoreElements()) {
filename = (String) filelist.nextElement();
imageNameVector.addElement(filename);
}
fc.close();
}
catch (IOException ioe)
{
System.out.println("IOException: "+ioe.getMessage());
}
catch (SecurityException se) {
System.out.println("SecurityException: "+se.getMessage());
}
System.out.checkError();
return imageNameVector;
}
現在我想找回從向量元素並將其轉換成圖像,
imageName = (String) imageNameVector.elementAt(1);
try{
image = Image.createImage(imageName);
}catch(Exception e){
Alert alert = new Alert("Sngjfkgnlkjf") ;
alert.setString(""+imageName+e);
display.setCurrent(alert);
}
它顯示了一個異常ABC,JPG不能被讀取,有人請幫我整理出來....