0
如何使用Java 7使用fileinputstream檢索和讀取本地文件。類似這樣但是對於本地文件。隨着新的安全設置,我不能讓它的工作Java 7使用文件輸入流檢索和讀取本地文件
public static InputStream openReading(String file)
throws FileNotFoundException
{
try
{
PersistenceService pService = (PersistenceService) ServiceManager
.lookup(PersistenceService.class.getCanonicalName());
URL fileurl = new URL(getCode() + file);
FileContents fc= pService.get(fileurl);
fc.setMaxLength(10240000);
InputStream in= fc.getInputStream();
return stream;
}
catch (MalformedURLException m)
{
m.printStackTrace();
}
catch (FileNotFoundException f)
{
throw new FileNotFoundException(f.getMessage());
}
}
'返回新的FileInputStream(文件);'代替你的整個方法體呢? –
@DavidWallace假設上下文從簽名但不可信的WebStart應用運行。 /'java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault()。getPath(file))'是Java SE 7做事的方式。 –
@ TomHawtin-tackline應用程序使用可信證書籤名,此方法不起作用 – user3375061