Object tryWithResources() throws OccasionalException { Object value = null; try (Resource resource = new Resource()) { occasionallyThrow(); value = new Object(); System.out.println(resource.toString()); } catch (CloseException e) { catchBlock(value, e); // call auxiliary method } return value; } void catchBlock(Object value, CloseException e) { if (value == null) { // then } else { // else } }
// list the statements in the Model StmtIterator iter = model.listStatements(); // print out the predicate, subject and object of each statement while (iter.hasNext()) { Statement stmt = iter.nextStatement(); // get next statement Resource subject = stmt.getSubject(); // get the subject Property predicate = stmt.getPredicate(); // get the predicate RDFNode object = stmt.getObject(); // get the object System.out.print(subject.toString()); System.out.print(" " + predicate.toString() + " "); if (object instanceof Resource) { System.out.print(object.toString()); } else { // object is a literal System.out.print(" \"" + object.toString() + "\""); } System.out.println(" ."); }
System.out.println(newResource.toString());
Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); if(subject.toString().equals (onto.uriBase+"#"+tabTF[0].getText()))