从Java applet访问java缓存

时间:2013-03-21 11:22:51

标签: java java-ee applet jvm japplet

我想知道是否可以直接从applet以动态方式从java访问缓存,换句话说,applet必须在多个操作系统中工作。

所有这一切都是因为我想在java缓存中加载文件,以便每次加载applet时都不必下载文件。

这就是我现在所拥有的:

    try {
        URL url = new URL( "http://www.dcc.fc.up.pt/~aaugusto/libpcsclite.so");
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.setDoOutput(true);
        urlConnection.connect();
        File file = new File("libpcsclite.so");
        System.out.println(file.length()+" "+file.exists());
        FileOutputStream fileOutput = new FileOutputStream(file);
        InputStream inputStream = urlConnection.getInputStream();
        //int totalSize = urlConnection.getContentLength();
        @SuppressWarnings("unused")
        int downloadedSize = 0;
        byte[] buffer = new byte[1024];
        int bufferLength = 0; //used to store a temporary size of the buffer
        while ((bufferLength = inputStream.read(buffer)) > 0 ) {
            fileOutput.write(buffer, 0, bufferLength);
            downloadedSize += bufferLength;
        }
        fileOutput.close();
        System.out.println(file.length()+" DAMN "+file.getPath());
        System.out.print(file.getAbsolutePath());
    } catch (IOException e) {
        e.printStackTrace();
    }
}

ps:我不能使用JNLP。我有签署小程序的证书

致以最诚挚的问候,

0 个答案:

没有答案