summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util/IOUtil.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-01 23:03:18 +0200
committerSven Gothel <[email protected]>2013-10-01 23:03:18 +0200
commitca7a1864a1624539048809d0a1c491f57c145d15 (patch)
treec2fcc0d522fe4ca6561cc31c31a7ed8e5a1c8238 /src/java/com/jogamp/common/util/IOUtil.java
parent3c9812c130fac9237a2dc2e18a6639ec3583eed7 (diff)
IOUtil/JarUtil: Add more detail debug information for URI transformation; IOUtil.toURL(..) handle exception at 'new File(uri)'
Diffstat (limited to 'src/java/com/jogamp/common/util/IOUtil.java')
-rw-r--r--src/java/com/jogamp/common/util/IOUtil.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java
index 6b9eef8..5918213 100644
--- a/src/java/com/jogamp/common/util/IOUtil.java
+++ b/src/java/com/jogamp/common/util/IOUtil.java
@@ -513,22 +513,40 @@ public class IOUtil {
* @throws URISyntaxException
*/
public static URL toURL(URI uri) throws IOException, IllegalArgumentException, URISyntaxException {
- final URL url;
+ URL url = null;
final String uriSchema = uri.getScheme();
final boolean isJAR = IOUtil.JAR_SCHEME.equals(uriSchema);
- final URI specificURI = isJAR ? JarUtil.getJarSubURI(uri) : uri;
+ final URI specificURI = isJAR ? JarUtil.getJarSubURI(uri) : uri;
+ int mode = 0;
if( IOUtil.FILE_SCHEME.equals( specificURI.getScheme() ) ) {
- final File f = new File(specificURI);
- if( specificURI == uri ) {
- url = new URL(IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+f.getPath());
- // url = f.toURI().toURL(); // Doesn't work, since it uses encoded path!
- } else {
- final String post = isJAR ? IOUtil.JAR_SCHEME_SEPARATOR + JarUtil.getJarEntry(uri) : "";
- final String urlS = uriSchema+IOUtil.SCHEME_SEPARATOR+IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+f.getPath()+post;
- url = new URL(urlS);
+ File f;
+ try {
+ f = new File(specificURI);
+ } catch( IllegalArgumentException iae) {
+ if( DEBUG ) {
+ System.out.println("toURL: "+uri+" -> File("+specificURI+") failed: "+iae.getMessage());
+ }
+ f = null;
}
- } else {
+ if( null != f ) {
+ if( specificURI == uri ) {
+ url = new URL(IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+f.getPath());
+ // url = f.toURI().toURL(); // Doesn't work, since it uses encoded path!
+ mode = 1;
+ } else {
+ final String post = isJAR ? IOUtil.JAR_SCHEME_SEPARATOR + JarUtil.getJarEntry(uri) : "";
+ final String urlS = uriSchema+IOUtil.SCHEME_SEPARATOR+IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+f.getPath()+post;
+ url = new URL(urlS);
+ mode = 2;
+ }
+ }
+ }
+ if( null == url ) {
url = uri.toURL();
+ mode = 3;
+ }
+ if( DEBUG ) {
+ System.err.println("IOUtil.toURL: "+uri+", isJar "+isJAR+": "+specificURI+" -> mode "+mode+", "+url);
}
return url;
}