comparison core/src/luan/modules/Utils.java @ 260:f1f7d8c7e94e

add Io.protocols git-svn-id: https://luan-java.googlecode.com/svn/trunk@261 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 28 Oct 2014 23:25:13 +0000
parents 4dfa86dbca45
children 5e7450ac27f2
comparison
equal deleted inserted replaced
259:f9b201530b85 260:f1f7d8c7e94e
71 } catch(IOException e) { 71 } catch(IOException e) {
72 throw new RuntimeException(e); 72 throw new RuntimeException(e);
73 } 73 }
74 } 74 }
75 */ 75 */
76 public static File toFile(String path) { 76 /*
77 private static File toFile(String path) {
77 if( path.contains("//") ) 78 if( path.contains("//") )
78 return null; 79 return null;
79 File file = new File(path); 80 File file = new File(path);
80 return file.exists() ? file : null; 81 return file.exists() ? file : null;
81 } 82 }
82 83
83 public static URL toUrl(String path) { 84 private static URL toUrl(String path) {
84 if( path.indexOf(':') == -1 ) 85 if( path.indexOf(':') == -1 )
85 return null; 86 return null;
86 if( path.startsWith("classpath:") ) { 87 if( path.startsWith("classpath:") ) {
87 path = path.substring(10); 88 path = path.substring(10);
88 if( path.contains("//") ) 89 if( path.contains("//") )
113 return new URL(path); 114 return new URL(path);
114 } catch(MalformedURLException e) {} 115 } catch(MalformedURLException e) {}
115 return null; 116 return null;
116 } 117 }
117 118
118 public static boolean exists(String path) { 119 static boolean exists(String path) {
119 return toFile(path)!=null || toUrl(path)!=null; 120 return toFile(path)!=null || toUrl(path)!=null;
120 } 121 }
122 */
121 } 123 }