Given a URL, this method returns all the 'file extensions' for the file part of the URL. For this purposes, a 'file extension' is any sequence of .-separated tokens (such as .gate.xml.gz). The order the extensions are returned in is from the most specific (longest) to the most generic (shortest) one
(URL url)
| 473 | * (shortest) one, e.g. [.gate.xml.gz, .xml.gz, .gz]. |
| 474 | */ |
| 475 | private static List<String> getFileSuffixes(URL url){ |
| 476 | List<String> res = new LinkedList<String>(); |
| 477 | if (url != null){ |
| 478 | // get the file name from the URL |
| 479 | String fileName = url.getPath(); |
| 480 | int pos = fileName.lastIndexOf('/'); |
| 481 | if(pos > 0) fileName = fileName.substring(pos); |
| 482 | pos = fileName.indexOf('.', 1); |
| 483 | while(pos > 0 && pos < fileName.length() - 1) { |
| 484 | res.add(fileName.substring(pos + 1)); |
| 485 | pos = fileName.indexOf('.', pos + 1); |
| 486 | } |
| 487 | } |
| 488 | return res; |
| 489 | } |
| 490 | |
| 491 | |
| 492 | /** |
no test coverage detected