我正在使用以下代码将插件“A”的资源文件夹中可用的图标复制到本地文件夹。这绝对没问题。现在我想知道是否有办法从其他插件(插件B)的资源文件夹中复制图标。我只需要在插件 A 中保留复制逻辑。有没有办法从当前插件访问其他插件的资源文件夹?
File objectDir = new File(directory + "/icons/");
if (!objectDir.exists()) {
objectDir.mkdirs();
}
InputStream inStream = null;
OutputStream outStream = null;
try {
File bfile = new File(directory + "/icons/validation.png");
inStream = this.getClass().getClassLoader().getResourceAsStream("/icons/viewAsHTML.png");
outStream = new FileOutputStream(bfile);
byte[] buffer = new byte[1024];
int length;
// copy the file content in bytes
while ((length = inStream.read(buffer)) > 0) {
outStream.write(buffer, 0, length);
}
inStream.close();
outStream.close();
System.out.println("File is copied successful!");
} catch (IOException e) {
e.printStackTrace();
}