Java Code Examples for org.apache.jena.atlas.io.IO#close()

The following examples show how to use org.apache.jena.atlas.io.IO#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRDFChangesGraph.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
private Graph replay() {
    IO.close(bout);
    final boolean DEBUG = false;

    if ( DEBUG ) {
        System.out.println("== Graph ==");
        RDFDataMgr.write(System.out, baseGraph, Lang.NQ);
        System.out.println("== Replay ==");
        String x = StrUtils.fromUTF8bytes(bout.toByteArray());
        System.out.print(x);
        System.out.println("== ==");
    }

    // A completely separate graph (different dataset)
    Graph graph2 = txnGraph();

    try(ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray())) {
        RDFPatchOps.applyChange(graph2, bin);
        if ( DEBUG ) {
            System.out.println("== Graph outcome ==");
            RDFDataMgr.write(System.out, graph2, Lang.NT);
            System.out.println("== ==");
        }
        return graph2;
    } catch (IOException ex) { IO.exception(ex); return null; }
}
 
Example 2
Source File: TestDeltaFusekiGood.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void afterClass() {
    if ( server1 != null )
        server1.stop();
    if ( server2 != null )
        server2.stop();
    deltaServer.stop();
    IO.close( ((CloseableHttpClient)HttpOp.getDefaultHttpClient()) );
    HttpOp.setDefaultHttpClient(dftStdHttpClient);
}
 
Example 3
Source File: Setup.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
/** Set the HttpClient - close the old one if appropriate */
/*package*/ static void setHttpClient(HttpClient newHttpClient) {
    HttpClient hc = HttpOp.getDefaultHttpClient() ;
    if ( hc instanceof CloseableHttpClient )
        IO.close((CloseableHttpClient)hc) ;
    HttpOp.setDefaultHttpClient(newHttpClient) ;

}
 
Example 4
Source File: OutputManagedFile.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
private void closeOutput() {
    if ( output == null )
        return;
    flushOutput();
    IO.close(output);
    //[gz] Compress currentFilename.
    output = null;
    fileOutput = null;
    // keep: currentFilename
    currentOutput = null;
}
 
Example 5
Source File: TestRDFChangesDataset.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
private DatasetGraph replay() {
    IO.close(bout);
    try(ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray())) {
        DatasetGraph dsg2 = DatasetGraphFactory.createTxnMem();
        RDFPatchOps.applyChange(dsg2, bin);
        return dsg2;
    } catch (IOException ex) { IO.exception(ex); return null; }
}
 
Example 6
Source File: TokenizerText.java    From RDFstarTools with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    IO.close(reader);
}
 
Example 7
Source File: TestDeltaFusekiBad.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
    IO.close( ((CloseableHttpClient)HttpOp.getDefaultHttpClient()) );
}
 
Example 8
Source File: TokenWriterText.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
@Override
public void close() {
    if ( inTuple ) {}
    IO.close(out);
}
 
Example 9
Source File: RDFChangesManagedOutput.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
private void finishOutput() {
    super.tok.flush();
    IO.close(currentStream);
    currentStream = null;
    super.tok = null;
}
 
Example 10
Source File: FileEntry.java    From rdf-delta with Apache License 2.0 3 votes vote down vote up
/**
 * Complete the write process: closes the OutputStream allocated by
 * {@link #openForWrite} thenn
 *
 * <p>
 * Note that {@code Outstream.close} is idempotent - it is safe
 * for the application to close the {@code Outstream}.
 * <p>
 * The application must flush any buffered output prior to calling {@code completeWrite}.
 */
public void completeWrite() {
    IO.close(out);
    IOX.move(tmpfile, datafile);
    haveWritten = true;
    out = null ;
}