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

The following examples show how to use java.net.URISyntaxException#toString() . These examples are extracted from open source projects. 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 Project: hadoop   File: CopyCommands.java    License: 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 Project: big-c   File: CopyCommands.java    License: 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
@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 Project: netbeans   File: JarClassLoader.java    License: 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 Project: hadoop   File: FsUrlConnection.java    License: 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 Project: hadoop   File: AbstractFSContract.java    License: 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 Project: big-c   File: FsUrlConnection.java    License: 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 Project: big-c   File: AbstractFSContract.java    License: 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
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 Project: RDFS   File: FsUrlConnection.java    License: 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 Project: hadoop-gpu   File: FsUrlConnection.java    License: 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 Project: netbeans   File: LayerBuilder.java    License: 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);
        }
    }
}