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

The following examples show how to use org.apache.jena.atlas.io.IO#exception() . 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: OutputManagedFile.java    From rdf-delta with Apache License 2.0 6 votes vote down vote up
private void nextFile() {
        try {
            currentFilename = roller.nextFilename();
            FmtLog.debug(LOG, "Setup: %s", currentFilename);
            // Must be a FileOutputStream so that getFD().sync is available.
            fileOutput = new FileOutputStream(currentFilename.toString(), true);
            output = new BufferedOutputStream(fileOutput);
            //[gz]
        } catch (FileNotFoundException ex) {
            IO.exception(ex);
            return;
//        } catch (IOException ex) {
//            IO.exception(ex);
//            return;
        }
    }
 
Example 2
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 3
Source File: OutputFixed.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
private void finish() {
    try {
        outputStream.flush();
        currentOutput = null;
    }
    catch (IOException e) {
        IO.exception(e); return;
    }
    if ( sema.availablePermits() == 0 )
        sema.release();
}
 
Example 4
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 5
Source File: TestRotate.java    From rdf-delta with Apache License 2.0 5 votes vote down vote up
/** "touch" - without metadata */
private static void touch(String filename) {
    Path p = DIR.resolve(filename);
    if ( ! Files.exists(p) ) {
        try ( OutputStream out = new FileOutputStream(p.toString()) ) {}
        catch (IOException ex) {
            IO.exception(ex);
        }
    }
}
 
Example 6
Source File: RDFPatchOps.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
/** Read an {@link RDFPatch} from a file. */
public static RDFPatch read(String filename) {
    try ( InputStream input = IO.openFile(filename) ) {
        return read(input);
    } catch (IOException ex) { IO.exception(ex); return null; }
}
 
Example 7
Source File: RDFPatchOps.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
/** Read an {@link RDFPatch} from a file. */
public static RDFPatch readBinary(String filename) {
    try ( InputStream input = IO.openFile(filename) ) {
        return readBinary(input);
    } catch (IOException ex) { IO.exception(ex); return null; }
}
 
Example 8
Source File: RDFChangesWriterBinary.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
public static void write(RDFPatch patch, String filename) {
    try ( OutputStream out = IO.openOutputFile(filename) ) {
        write(patch, out);
    } catch (IOException ex) { IO.exception(ex); }
}