MCPcopy Create free account
hub / github.com/GateNLP/gate-core / fileFromURL

Method fileFromURL

src/main/java/gate/util/Files.java:640–654  ·  view source on GitHub ↗

Convert a file: URL to a java.io.File . First tries to parse the URL's toExternalForm as a URI and create the File object from that URI. If this fails, just uses the path part of the URL. This handles URLs that contain spaces or other unusual characters, both as literals and when enco

(URL theURL)

Source from the content-addressed store, hash-verified

638 * File.
639 */
640 public static File fileFromURL(URL theURL) throws IllegalArgumentException {
641 try {
642 URI uri = new URI(theURL.toExternalForm());
643 return new File(uri);
644 }
645 catch(URISyntaxException use) {
646 try {
647 URI uri = new URI(theURL.getProtocol(), null, theURL.getPath(), null, null);
648 return new File(uri);
649 }
650 catch(URISyntaxException use2) {
651 throw new IllegalArgumentException("Cannot convert " + theURL + " to a file path");
652 }
653 }
654 }
655
656 /**
657 * Same as {@link java.io.File#listFiles(java.io.FileFilter)}

Callers 15

writeUserConfigMethod · 0.95
populateMethod · 0.95
checkIndexParametersMethod · 0.95
createIndexMethod · 0.95
getSelectedFileMethod · 0.95
setStorageUrlMethod · 0.95
openMethod · 0.95
findSubclassesMethod · 0.95
readMethod · 0.95
writeMethod · 0.95
executeMethod · 0.95
copyDirectoriesMethod · 0.95

Calls 1

toExternalFormMethod · 0.80

Tested by

no test coverage detected