Java Code Examples for java.net.URISyntaxException#toString()

The following examples show how to use java.net.URISyntaxException#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyCommands.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PathData> expandArgument(String arg) throws IOException {
  List<PathData> items = new LinkedList<PathData>();
  if (arg.equals("-")) {
    readStdin = true;
  } else {
    try {
      items.add(new PathData(new URI(arg), getConf()));
    } catch (URISyntaxException e) {
      if (Path.WINDOWS) {
        // Unlike URI, PathData knows how to parse Windows drive-letter paths.
        items.add(new PathData(arg, getConf()));
      } else {
        throw new IOException("Unexpected URISyntaxException: " + e.toString());
      }
    }
  }
  return items;
}
 
Example 2
Source File: CopyCommands.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PathData> expandArgument(String arg) throws IOException {
  List<PathData> items = new LinkedList<PathData>();
  if (arg.equals("-")) {
    readStdin = true;
  } else {
    try {
      items.add(new PathData(new URI(arg), getConf()));
    } catch (URISyntaxException e) {
      if (Path.WINDOWS) {
        // Unlike URI, PathData knows how to parse Windows drive-letter paths.
        items.add(new PathData(arg, getConf()));
      } else {
        throw new IOException("Unexpected URISyntaxException: " + e.toString());
      }
    }
  }
  return items;
}
 
Example 3
Source File: GenomicsDBImportUnitTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test(dataProvider = "getSampleMaps")
public void testLoadSampleNameMapFileInSortedOrder(final String sampleMapText){
    final File sampleFile = IOUtils.writeTempFile(sampleMapText, "sampleMapping", ".txt");
    final Map<String, URI> expected = new LinkedHashMap<>();
    try {
        expected.put("Sample1", new URI("file1"));
        expected.put("Sample2", new URI("file2"));
        expected.put("Sample3", new URI("file3"));
    }
    catch(URISyntaxException e) {
        throw new RuntimeException("Malformed URI "+e.toString());
    }
    final Map<String, URI> actual = GenomicsDBImport.loadSampleNameMapFileInSortedOrder(sampleFile.toPath());
    Assert.assertEquals(actual, expected);
    Assert.assertEquals(actual.keySet().iterator().next(), "Sample1");
}
 
Example 4
Source File: JarClassLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected URL doGetResource(String name) throws IOException  {
    byte[] buf = archive.getData(this, name);
    if (buf == null) return null;
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.log(Level.FINER, "Loading {0} from {1}", new Object[] {name, file.getPath()});
    }
    try {
        return new URL(null, resPrefix + new URI(null, name, null).getRawPath(), new JarURLStreamHandler(jcl));
    } catch (URISyntaxException x) {
        throw new IOException(name + " in " + resPrefix + ": " + x.toString(), x);
    }
}
 
Example 5
Source File: FsUrlConnection.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws IOException {
  try {
    FileSystem fs = FileSystem.get(url.toURI(), conf);
    is = fs.open(new Path(url.getPath()));
  } catch (URISyntaxException e) {
    throw new IOException(e.toString());
  }
}
 
Example 6
Source File: AbstractFSContract.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Create a URI off the scheme
 * @param path path of URI
 * @return a URI
 * @throws IOException if the URI could not be created
 */
protected URI toURI(String path) throws IOException {
  try {
    return new URI(getScheme(),path, null);
  } catch (URISyntaxException e) {
    throw new IOException(e.toString() + " with " + path, e);
  }
}
 
Example 7
Source File: FsUrlConnection.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws IOException {
  try {
    FileSystem fs = FileSystem.get(url.toURI(), conf);
    is = fs.open(new Path(url.getPath()));
  } catch (URISyntaxException e) {
    throw new IOException(e.toString());
  }
}
 
Example 8
Source File: AbstractFSContract.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Create a URI off the scheme
 * @param path path of URI
 * @return a URI
 * @throws IOException if the URI could not be created
 */
protected URI toURI(String path) throws IOException {
  try {
    return new URI(getScheme(),path, null);
  } catch (URISyntaxException e) {
    throw new IOException(e.toString() + " with " + path, e);
  }
}
 
Example 9
Source File: AuthorizationMetadataService.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static URI removeDefaultPort(URI uri) {
    if ((uri.getPort() == 80 && "http".equals(uri.getScheme()))
            || (uri.getPort() == 443 && "https".equals(uri.getScheme()))) {
        try {
            return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), -1,
                    uri.getPath(), uri.getQuery(), uri.getFragment());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Invalid URI " + uri + " : " + e.toString(), e);
        }
    }
    return uri;
}
 
Example 10
Source File: FsUrlConnection.java    From RDFS with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws IOException {
  try {
    FileSystem fs = FileSystem.get(url.toURI(), conf);
    is = fs.open(new Path(url.getPath()));
  } catch (URISyntaxException e) {
    throw new IOException(e.toString());
  }
}
 
Example 11
Source File: FsUrlConnection.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
@Override
public void connect() throws IOException {
  try {
    FileSystem fs = FileSystem.get(url.toURI(), conf);
    is = fs.open(new Path(url.getPath()));
  } catch (URISyntaxException e) {
    throw new IOException(e.toString());
  }
}
 
Example 12
Source File: LayerBuilder.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Allows a processor to accept relative resource paths.
 * For example, to produce the output value {@code net/nowhere/lib/icon.png}
 * given an element in the package {@code net.nowhere.app}, the following inputs are permitted:
 * <ul>
 * <li>{@code ../lib/icon.png}
 * <li>{@code /net/nowhere/lib/icon.png}
 * </ul>
 * @param originatingElement the annotated element, used for its package
 * @param resource a possibly relative resource path
 * @return an absolute resource path (with no leading slash)
 * @throws LayerGenerationException in case the resource path is malformed
 * @since 7.51
 */
public static String absolutizeResource(Element originatingElement, String resource) throws LayerGenerationException {
    if (resource.startsWith("/")) {
        return resource.substring(1);
    } else {
        try {
            return new URI(null, findPackage(originatingElement).replace('.', '/') + "/", null).resolve(new URI(null, resource, null)).getPath();
        } catch (URISyntaxException x) {
            throw new LayerGenerationException(x.toString(), originatingElement);
        }
    }
}