You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/10/08 16:26:19 UTC
[7/7] jena git commit: Use try-resource
Use try-resource
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/06628e70
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/06628e70
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/06628e70
Branch: refs/heads/master
Commit: 06628e70ff8a8127cd8d4a812249a9f1e6b052a6
Parents: 7308f32
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Oct 8 17:25:36 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 8 17:25:36 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/riot/writer/TestJsonLDWriter.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/06628e70/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
index f1eef17..82aaa6b 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
@@ -466,19 +466,14 @@ public class TestJsonLDWriter extends BaseTest {
//
private String toString(Model m, RDFFormat f, Context jenaContext) {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
+ try(ByteArrayOutputStream out = new ByteArrayOutputStream()) {
WriterDatasetRIOT w = RDFDataMgr.createDatasetWriter(f) ;
DatasetGraph g = DatasetFactory.create(m).asDatasetGraph();
PrefixMap pm = RiotLib.prefixMap(g);
String base = null;
w.write(out, g, pm, base, jenaContext) ;
-
out.flush();
- String x = out.toString("UTF-8");
- out.close();
- return x;
+ return out.toString("UTF-8");
} catch (IOException e) { throw new RuntimeException(e); }
}