Revision 3069
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/util/URLUtils.java | ||
---|---|---|
178 | 178 |
} |
179 | 179 |
return url; |
180 | 180 |
} |
181 |
|
|
182 |
public static boolean isFileURL(URL url) { |
|
183 |
String protocol = url.getProtocol(); |
|
184 |
return StringUtils.equalsIgnoreCase(protocol, "file"); |
|
185 |
} |
|
181 | 186 |
|
182 | 187 |
public static void main(String[] args) throws MalformedURLException { |
183 | 188 |
File f = new File("C:\\Users\\jolic\\gvSIG\\plugins\\org.gvsig.scripting.app.mainplugin\\2.5.1\\scripts\\addons\\Arena2Reader\\i18n\\text.properties"); |
... | ... | |
185 | 190 |
URLUtils.openStream(new URL("file:/C:/text.properties")); |
186 | 191 |
URLUtils.openStream(new URL("file://C:/text.properties")); |
187 | 192 |
URLUtils.openStream(new URL("file:///C:/text.properties")); |
193 |
URLUtils.openStream(new URL("file:////etc/hosts")); |
|
194 |
URLUtils.isFileURL(new URL("file:////etc/hosts")); |
|
195 |
URLUtils.toFile(new URL("file:////etc/hosts")); |
|
196 |
URLUtils.toFile(new URL("file:///etc/hosts")); |
|
188 | 197 |
} |
189 | 198 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultSimpleImage.java | ||
---|---|---|
30 | 30 |
import org.apache.commons.lang3.StringUtils; |
31 | 31 |
import org.apache.commons.lang3.mutable.MutableObject; |
32 | 32 |
import org.gvsig.tools.swing.api.SimpleImage; |
33 |
import org.gvsig.tools.util.URLUtils; |
|
33 | 34 |
|
34 | 35 |
/** |
35 | 36 |
* |
... | ... | |
176 | 177 |
} |
177 | 178 |
|
178 | 179 |
} else if (source instanceof URL) { |
179 |
theImage = ImageIO.read((URL) source); |
|
180 |
if(URLUtils.isFileURL((URL) source)){ |
|
181 |
theImage = ImageIO.read(URLUtils.toFile((URL) source)); |
|
182 |
} else { |
|
183 |
theImage = ImageIO.read((URL) source); |
|
184 |
} |
|
180 | 185 |
if( formatName!=null ) { |
181 | 186 |
formatName.setValue(this.getFormatName(source)); |
182 | 187 |
} |
Also available in: Unified diff