jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [7/7] jena git commit: Use try-resource
Date Sat, 08 Oct 2016 16:26:19 GMT
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 <andy@apache.org>
Authored: Sat Oct 8 17:25:36 2016 +0100
Committer: Andy Seaborne <andy@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); }
     }
 


Mime
View raw message