Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 7使用fileinput流检索和读取本地文件_Java_Security_File Permissions_Fileinputstream - Fatal编程技术网

Java 7使用fileinput流检索和读取本地文件

Java 7使用fileinput流检索和读取本地文件,java,security,file-permissions,fileinputstream,Java,Security,File Permissions,Fileinputstream,如何使用Java7使用fileinputstream检索和读取本地文件。类似这样的内容,但用于本地文件。有了新的安全设置,我无法让它工作 public static InputStream openReading(String file) throws FileNotFoundException { try { PersistenceService pService = (PersistenceService) ServiceManager .lookup

如何使用Java7使用fileinputstream检索和读取本地文件。类似这样的内容,但用于本地文件。有了新的安全设置,我无法让它工作

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());   
}
}

ExtendedService.openFile
等同于打开文件。这提供了读/写访问权限。没有选项要求只读

返回新文件inputstream(文件)有什么问题
替代整个方法体?@DavidWallace上下文可能是从已签名但不受信任的WebStart应用程序运行的
java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPath(file))
是java SE 7的工作方式。@TomHawtin tackline该应用程序是使用此方法不起作用的可信证书签名的well@user3375061“可信证书”是指有效的证书。即使证书有效,也不意味着应用程序以本地用户的身份请求对mess about的完全访问权(用户也不允许这样做)。/不确定你所说的“这种方法也不管用”是什么意思<代码>文件。newInputStreamvs
新文件InputStream
?您上面的评论有效。Java 7现在使用Java.nio.file,如您所示。。。感谢java.nio.file.Files.newInputStream(java.nio.file.FileSystems.getDefault().getPa‌​th(文件))