public static void main(String argv[]) {
Hashtable v = new Hashtable();
File f = new File("images/");
File fs[] = f.listFiles();
for (int i = 0; i < fs.length-1; i++) {
v.put(fs[i].getName(),new javax.swing.ImageIcon(fs[i].getAbsolutePath()));
}
writeObjectToFile("JTP", v);
} /**
*写入文件
* @param fileName
* @param obj
* @return
*/
public static boolean writeObjectToFile(String fileName, Object obj) {
try {
if (! (obj instanceof Serializable))
return false;
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fileName));
out.writeObject(obj);
out.flush();
out.close();
return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
}为什么程序报java.io.IOException: failed to load image contents
Hashtable v = new Hashtable();
File f = new File("images/");
File fs[] = f.listFiles();
for (int i = 0; i < fs.length-1; i++) {
v.put(fs[i].getName(),new javax.swing.ImageIcon(fs[i].getAbsolutePath()));
}
writeObjectToFile("JTP", v);
} /**
*写入文件
* @param fileName
* @param obj
* @return
*/
public static boolean writeObjectToFile(String fileName, Object obj) {
try {
if (! (obj instanceof Serializable))
return false;
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fileName));
out.writeObject(obj);
out.flush();
out.close();
return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
}为什么程序报java.io.IOException: failed to load image contents
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货