1

我在将 Blazegraph 属性文件加载到嵌入式实例时遇到问题。当我尝试将.properties文件导入我的 Java 类时,我收到以下错误:

Exception in thread "main" java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.Reader.read(Unknown Source)
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at blazegraph_tinkerpop_tryout.blazegraph_data_load.loadProperties(blazegraph_data_load.java:55)
at blazegraph_tinkerpop_tryout.blazegraph_data_load.main(blazegraph_data_load.java:32)

从 main调用loadProperties函数:

Properties props = loadProperties("sampleprops.properties");

我的loadProperties功能(检查文件路径是否有效,然后发送给阅读器):

public static Properties loadProperties(String resource) throws IOException 
{
    Properties p = new Properties();
    Path path = Paths.get(resource);
    Boolean bool = Files.exists(path);
    if (bool)
    {
        System.out.println("File was found. Attempting data load...");
        InputStream is = blazegraph_data_load.class.getResourceAsStream(resource);
        p.load(new InputStreamReader(new BufferedInputStream(is)));
        return p;
    }
    System.out.println("The file you entered was not found.");
    return null;
}

这是我的文件sampleprops.properties 的样子:

com.bigdata.journal.AbstractJournal.bufferMode=DiskRW
com.bigdata.journal.AbstractJournal.file=blazegraph.jnl

我一直按照此处描述的示例 Blazegraph 应用程序中的设置说明进行操作。如果它有所作为,我将使用此处找到的 Blazegraph/Tinkerpop3 实现。

4

1 回答 1

0

我找到了一种解决方法:我将getResourceAsStream方法切换为一种FileInputStream方法。

问题在于我的属性文件的位置。该FileInputStream方法在放置文件的位置似乎更宽容。

于 2017-03-14T16:37:42.713 回答