summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/common-java/src/main/java/org/apache
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-08-12 23:43:27 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-08-12 23:43:27 +0000
commitc122a7379b57d45d2c994728171d20609842f7c5 (patch)
tree9ea10773724f65216b0ebe8d155db4dabaca08f9 /java/sca/modules/common-java/src/main/java/org/apache
parentaaa85d1773cf5740e22913a9b5027f0bfebbf1de (diff)
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
Diffstat (limited to 'java/sca/modules/common-java/src/main/java/org/apache')
-rw-r--r--java/sca/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java19
1 files changed, 18 insertions, 1 deletions
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:<relative path> 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