0

次のコードを使用して、プラグイン「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();
    }
4

1 に答える 1

2

platform:/plugin/次のメカニズムを使用して、別のプラグインのリソースを取得できるはずです。

url = new URL("platform:/plugin/your.plugin.package.pluginB/icons/validation.png");
InputStream inputStream = url.openConnection().getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
于 2013-04-23T13:54:53.800 に答える