271 |
abstract InputStream getInputStream() throws IOException; |
abstract InputStream getInputStream() throws IOException; |
272 |
} |
} |
273 |
|
|
274 |
|
/** |
275 |
|
* Returns the given URL with a canonicalized file path name when it |
276 |
|
* is has the file protocol. Otherwise (or when the file part of the |
277 |
|
* URL couldn't be canonicalized) it returns the original String. |
278 |
|
* It makes sure that if the original file part ended with a file |
279 |
|
* separator that the new file part also ends with a separator. |
280 |
|
*/ |
281 |
static URL getCanonicalFileURL(URL url) |
static URL getCanonicalFileURL(URL url) |
282 |
{ |
{ |
283 |
if ("file".equals(url.getProtocol())) |
if ("file".equals(url.getProtocol())) |
284 |
{ |
{ |
285 |
try |
try |
286 |
{ |
{ |
287 |
File f = new File(url.getFile()).getCanonicalFile(); |
String f = url.getFile(); |
288 |
url = new URL("file", "", f.toString()); |
File file = new File(f).getCanonicalFile(); |
289 |
|
String cf = file.toString(); |
290 |
|
String sep = File.separator; |
291 |
|
if (f.endsWith(sep) && !cf.endsWith(sep)) |
292 |
|
{ |
293 |
|
cf += "/"; |
294 |
|
} |
295 |
|
url = new URL("file", "", cf); |
296 |
} |
} |
297 |
catch (IOException ignore) |
catch (IOException ignore) |
298 |
{ |
{ |