List of usage examples for java.net URI toURL
public URL toURL() throws MalformedURLException
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("filename"); URI uri = file.toURI(); file = new File(uri.toURL().getFile()); InputStream is = uri.toURL().openStream(); is.close();//from w w w. ja v a 2 s .c om }
From source file:Main.java
public static void main(String[] args) throws Exception { URI uri = new URI("http://java2s.com/"); URL url = uri.toURL(); System.out.println(url);//w w w . j av a 2 s .co m }
From source file:Main.java
public static void main(String[] argv) throws Exception { File file = new File("filename"); URI uri = file.toURI(); System.out.println(uri);//from w w w . ja v a2 s . c o m file = new File(uri.toURL().getFile()); InputStream is = uri.toURL().openStream(); is.close(); }
From source file:Test.java
public static void main(String[] args) throws Exception { Path newFile = FileSystems.getDefault().getPath("C:/h.html"); URI url = URI.create("http://jdk7.java.net/"); InputStream inputStream = url.toURL().openStream(); Files.copy(inputStream, newFile); System.out.println("Site copied successfully!"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { URI uri = null; URL url = null;/*from www . j a va 2 s. c o m*/ // Create a URI uri = new URI("file://D:/1.4/Ex1.java"); url = uri.toURL(); uri = new URI(url.toString()); }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UmlsCommon.LoadRRFToDB.java
public static void main(String[] args) throws Exception { URI testURI = new URI("http://www.cnn.com/"); // URI testURI = new URI("file:///W:/temp"); // System.out.println(new File(testURI).exists()); HttpURLConnection connecition = (HttpURLConnection) testURI.toURL().openConnection(); System.out.println(connecition.getResponseCode()); System.out.println(testURI.resolve("TEST").toString()); }
From source file:com.infullmobile.jenkins.plugin.restrictedregister.util.AppUrls.java
@Nonnull public static String buildSignInUrl() throws InvalidUriException { String ret = null;/*from w w w .jav a 2 s . c om*/ final String path = String.format(Locale.US, FORMAT_LOGIN_PATH, PluginModule.getDefault().getJenkinsDescriptor().getLoginURI()); try { final URIBuilder builder = new URIBuilder(getRootURL()); builder.setPath(path); final URI uri = builder.build(); ret = uri.toURL().toExternalForm(); } catch (URISyntaxException | MalformedURLException e) { onError(e.getLocalizedMessage()); } return ret; }
From source file:com.infullmobile.jenkins.plugin.restrictedregister.util.AppUrls.java
@Nonnull public static String buildActivationUrl(String code, String secret) throws InvalidUriException { String ret = null;/*from w w w . j a v a 2 s . co m*/ final String path = String.format(Locale.US, FORMAT_REGISTER_PATH, PluginModule.getDefault().getPluginDescriptor().getRootActionURL()); try { final URIBuilder builder = new URIBuilder(getRootURL()); builder.setPath(path); builder.addParameter(BaseFormField.SECRET.getFieldName(), secret); builder.addParameter(BaseFormField.ACTIVATION_CODE.getFieldName(), code); final URI uri = builder.build(); ret = uri.toURL().toExternalForm(); } catch (URISyntaxException | MalformedURLException e) { onError(e.getLocalizedMessage()); } return ret; }
From source file:io.github.swagger2markup.utils.IOUtils.java
/** * Create a reader from specified {@code source}.<br> * Returned reader should be explicitly closed after use. * * @param uri source URI/*from w w w . ja v a 2 s . co m*/ * @return reader * @throws IOException if the connection cannot be opened */ public static Reader uriReader(URI uri) throws IOException { return new BufferedReader(new InputStreamReader(uri.toURL().openStream(), StandardCharsets.UTF_8)); }
From source file:framework.json2java.Example.java
private static JCodeModel generate(String fileName, String className, String packageName) throws URISyntaxException, IOException { JCodeModel codeModel = new JCodeModel(); URI uri = Example.class.getResource(fileName).toURI(); new SchemaMapper().generate(codeModel, className, packageName, uri.toURL()); return codeModel; }