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