我想知道是否可以直接从小程序以动态方式从 java 访问缓存,换句话说,小程序必须在多个操作系统中工作。
所有这一切都是因为我想在 java 缓存中加载一个文件,以便不必在每次加载小程序时都下载该文件。
这就是我现在所拥有的:
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。我有证书可以签署小程序
此致,