| 86 | | if( endIdx == -1 ) { |
|---|
| 87 | | throw new RuntimeException("Failed expanding Jar."); |
|---|
| 88 | | } |
|---|
| 89 | | String unescaped = null; |
|---|
| 90 | | String fileNamePart = stringForm.substring("jar:file:".length(), endIdx); |
|---|
| 91 | | file = new File(fileNamePart); |
|---|
| 92 | | file = new File( file.getName() ); |
|---|
| 93 | | |
|---|
| 94 | | /* |
|---|
| 95 | | if ( !file.exists()) { |
|---|
| 96 | | // try to unescape encase the URL Handler has escaped the " " to %20 |
|---|
| 97 | | unescaped = unescape(fileNamePart); |
|---|
| 98 | | file = new File(unescaped); |
|---|
| 99 | | } |
|---|
| 100 | | */ |
|---|
| 101 | | return file; |
|---|
| 102 | | |
|---|
| | 78 | if(endIdx != -1){ |
|---|
| | 79 | String unescaped = null; |
|---|
| | 80 | String fileNamePart = stringForm.substring("jar:file:".length(), endIdx); |
|---|
| | 81 | file = new File(fileNamePart); |
|---|
| | 82 | if ( ! file.exists()) { |
|---|
| | 83 | // try to unescape encase the URL Handler has escaped the " " to %20 |
|---|
| | 84 | unescaped = unescape(fileNamePart); |
|---|
| | 85 | file = new File(unescaped); |
|---|
| | 86 | } |
|---|
| | 87 | return file; |
|---|
| | 88 | } |
|---|
| | 89 | throw new RuntimeException("Failed expanding Jar."); |
|---|
| 467 | | StringBuffer sb = new StringBuffer(s.length()); |
|---|
| 468 | | |
|---|
| 469 | | for (int i = 0; i < s.length(); i++) { |
|---|
| 470 | | char c = s.charAt(i); |
|---|
| 471 | | switch (c) { |
|---|
| 472 | | case '%': { |
|---|
| 473 | | try { |
|---|
| 474 | | sb.append( (char) Integer.parseInt(s.substring(i + 1, i + 3), 16)); |
|---|
| 475 | | i += 2; |
|---|
| 476 | | break; |
|---|
| 477 | | } |
|---|
| 478 | | catch (NumberFormatException nfe) { |
|---|
| 479 | | throw new IllegalArgumentException(); |
|---|
| 480 | | } |
|---|
| 481 | | catch (StringIndexOutOfBoundsException siob) { |
|---|
| 482 | | String end = s.substring(i); |
|---|
| 483 | | sb.append(end); |
|---|
| 484 | | if (end.length() == 2) i++; |
|---|
| 485 | | } |
|---|
| 486 | | break; |
|---|
| 487 | | } |
|---|
| 488 | | default: { |
|---|
| 489 | | sb.append(c); |
|---|
| 490 | | break; |
|---|
| 491 | | } |
|---|
| 492 | | } |
|---|
| 493 | | } |
|---|
| 494 | | return sb.toString(); |
|---|
| | 454 | |
|---|
| | 455 | URLDecoder ud = new URLDecoder(); |
|---|
| | 456 | |
|---|
| | 457 | String decoded = null; |
|---|
| | 458 | |
|---|
| | 459 | try { |
|---|
| | 460 | decoded = ud.decode( s, "UTF-8" ); |
|---|
| | 461 | } catch ( java.io.UnsupportedEncodingException uee ) { |
|---|
| | 462 | System.err.println( "unsupported encoding" ); |
|---|
| | 463 | return s; |
|---|
| | 464 | } |
|---|
| | 465 | return decoded; |
|---|