private InputStream openChangesSrc(String x) { // May change to cope with remote source return IO.openFile(x) ; }
private static Reader openFileReader(String filename, Charset charset) { InputStream in = openFile(filename) ; return new InputStreamReader(in, charset) ; }
private static Reader openFileReader(String filename, Charset charset) { InputStream in = openFile(filename) ; return new InputStreamReader(in, charset) ; }
private static Reader openFileReader(String filename, Charset charset) { InputStream in = openFile(filename) ; return new InputStreamReader(in, charset) ; }
/** * Decode the contents of the input stream and send to the {@link StreamRDF}. * @param filename */ public static TProtocol protocol(String filename) { InputStream in = IO.openFile(filename) ; TProtocol protocol = protocol(in) ; return protocol ; }
public static LangRDFXML create(String xmlBase, String filename, ErrorHandler errorHandler, StreamRDF sink) { return create(IO.openFile(filename), xmlBase, filename, errorHandler, sink) ; }
public static CSVParser create(String filename) { InputStream input = IO.openFile(filename) ; return create(input) ; }
public static void main(String... args) { if ( args.length == 0 ) { args = new String[] {"-"} ; } if ( args.length != 1 ) { System.err.println("Usage: "+Lib.classShortName(dumpthrift.class)+" FILE") ; System.exit(2) ; } // Leave a general loop ... for ( String fn : args ) { InputStream in = IO.openFile(fn) ; BinRDF.dump(System.out, in) ; } } }
public static void main(String... args) { if ( args.length == 0 ) { args = new String[] {"-"} ; } if ( args.length != 1 ) { System.err.println("Usage: "+Lib.classShortName(dumpthrift.class)+" FILE") ; System.exit(2) ; } // Leave a general loop ... for ( String fn : args ) { InputStream in = IO.openFile(fn) ; BinRDF.dump(System.out, in) ; } } }
/** Create an UpdateRequest by reading it from a file */ public static UpdateRequest read(UsingList usingList, String fileName, String baseURI, Syntax syntax) { InputStream in = null ; if ( fileName.equals("-") ) in = System.in ; else { in = IO.openFile(fileName) ; if ( in == null ) throw new UpdateException("File could not be opened: "+fileName) ; } return read(usingList, in, baseURI, syntax) ; }
/** Parse update operations into a GraphStore by reading it from a file */ public static void parseExecute(UsingList usingList, DatasetGraph dataset, String fileName, Binding inputBinding, String baseURI, Syntax syntax) { InputStream in = null ; if ( fileName.equals("-") ) in = System.in ; else { in = IO.openFile(fileName) ; if ( in == null ) throw new UpdateException("File could not be opened: "+fileName) ; } parseExecute(usingList, dataset, in, inputBinding, baseURI, syntax) ; }
/** * Decode the contents of the file and send to the {@link StreamRDF}. * A filename ending {@code .gz} will have a gzip decompressor added. * A filename of "-" is {@code System.in}. * @param filename The file. * @param dest Sink */ public static void fileToStream(String filename, StreamRDF dest) { InputStream in = IO.openFile(filename) ; TProtocol protocol = TRDF.protocol(in) ; protocolToStream(protocol, dest) ; }
/** * Load a result set from file or URL into a result set (memory backed). * * @param filenameOrURI * @param format * @return ResultSet */ public static ResultSet load(String filenameOrURI, ResultsFormat format) { if (format == null) format = ResultsFormat.guessSyntax(filenameOrURI); InputStream in = IO.openFile(filenameOrURI) ; return load(in, format) ; }
protected static PropertyTable fillPropertyTable(PropertyTable table, String csvFilePath ){ InputStream input = IO.openFile(csvFilePath) ; CSVParser iterator = CSVParser.create(input) ; return fillPropertyTable(table, iterator, csvFilePath); }
/** Parse update operations into a GraphStore by reading it from a file */ @SuppressWarnings("resource") public static void parseExecute(UsingList usingList, DatasetGraph dataset, String fileName, Binding inputBinding, String baseURI, Syntax syntax) { InputStream in = null ; if ( fileName.equals("-") ) in = System.in ; else { in = IO.openFile(fileName) ; if ( in == null ) throw new UpdateException("File could not be opened: "+fileName) ; } parseExecute(usingList, dataset, in, inputBinding, baseURI, syntax) ; if ( in != System.in ) IO.close(in) ; }
@Test public void resultSet_10() { try (InputStream in = IO.openFile(DIR+"/results-1.srj")) { ResultSet rs = ResultSetFactory.fromJSON(in) ; test(ResultSetFactory.copyResults(rs)) ; } catch (IOException ex) { IO.exception(ex) ; } } }
@Test public void load_dataset_02() { DatasetGraphTDB dsg = fresh() ; InputStream in = IO.openFile(DIR + "data-1.nq") ; TDBLoader.load(dsg, in, false) ; assertTrue(dsg.getDefaultGraph().isEmpty()) ; assertEquals(1, dsg.getGraph(g).size()) ; }
@Test public void load_dataset_02() { DatasetGraphTDB dsg = fresh() ; InputStream in = IO.openFile(DIR + "data-1.nq") ; TDBLoader.load(dsg, in, false) ; assertTrue(dsg.getDefaultGraph().isEmpty()) ; assertEquals(1, dsg.getGraph(g).size()) ; }
@Test(expected=RiotException.class) public void trix_bad() { ErrorHandler err = ErrorHandlerFactory.getDefaultErrorHandler() ; try { ErrorHandlerFactory.setDefaultErrorHandler(ErrorHandlerFactory.errorHandlerSimple()) ; InputStream in = IO.openFile(fInput) ; StreamRDF sink = StreamRDFLib.sinkNull() ; RDFParser.source(in).lang(Lang.TRIX).parse(sink); } finally { ErrorHandlerFactory.setDefaultErrorHandler(err) ; } } }
@Test public void trix_direct() { ReaderRIOT r = new ReaderTriX(RiotLib.dftProfile(), ErrorHandlerFactory.errorHandlerNoWarnings); InputStream in = IO.openFile(fInput) ; DatasetGraph dsg = DatasetGraphFactory.create() ; //StreamRDF stream = StreamRDFLib.writer(System.out) ; StreamRDF stream = StreamRDFLib.dataset(dsg) ; stream.start(); r.read(in, null, null, stream, null) ; stream.finish(); if ( fExpected != null ) { DatasetGraph dsg2 = RDFDataMgr.loadDatasetGraph(fExpected) ; boolean b = IsoMatcher.isomorphic(dsg, dsg2) ; if ( ! b ) { Assert.fail("Not isomorphic") ; } } }