From c122a7379b57d45d2c994728171d20609842f7c5 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 12 Aug 2009 23:43:27 +0000 Subject: Fix issues around XMLStreamWriter based on the isRepairingNamespaces property of XMLOutputFactory More refactoring to use common-xml and common-java git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@803742 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/common/java/io/IOHelper.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'java/sca/modules/common-java/src/main/java/org/apache') diff --git a/java/sca/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java b/java/sca/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java index 94aa7220e1..f43ff4538b 100644 --- a/java/sca/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java +++ b/java/sca/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.common.java.io; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.JarURLConnection; @@ -29,10 +30,16 @@ import java.net.URL; import java.net.URLConnection; /** - * + * Helper class for I/O operations */ public class IOHelper { + public static InputStream openStream(URL url) throws IOException { + // Handle file: which strictly speaking is not a valid file URL + File file = toFile(url); + if (file != null) { + return new FileInputStream(file); + } URLConnection connection = url.openConnection(); if (connection instanceof JarURLConnection) { // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041014 @@ -42,6 +49,16 @@ public class IOHelper { return is; } + public static void close(InputStream is) { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + } + /** * Escape the space in URL string * @param uri -- cgit v1.2.3