}
if(!filePath.contains("GetVerticesMVC") || !filePath.endsWith(".jar")) {
String str = "此工具专门为 GetVerticesMVC 设计,不通用!! 请注意!!";
JOptionPane.showMessageDialog(null, str);
break;
}
System.out.println("jarFilePath=" + filePath);
jce.setJarFile(file);
JarFile jarFile = null;
try {
jarFile = new JarFile(filePath);
ZipEntry entry = jarFile.getEntry(jce.configPath);
if(entry == null) {
System.out.println(jce.configPath+"路径所代表的文件不存在!读取失败~");
// 安全起见,将 jarFile 置为 null,这样在关闭窗口的时候将不会执行收尾操作~
jce.setJarFile(null);
break;
}
//获取到inputstream了 就相当简单了
byte[] bytes = JarCfgEditor.inputStream2byteArray(is);
String cfgStr = new String(bytes);
jce.getJta().setText(cfgStr);
} catch (IOException e) {
e.printStackTrace();
}
}
// 一次只能处理一个,要避免处理多个的情况,因此 break 跳出~
break;
}
event.dropComplete(true);
} else {
event.rejectDrop();
}
}
}
摘自 yang3wei的专栏