List of usage examples for java.net URL getFile
public String getFile()
From source file:com.macdonst.ftpclient.FtpClient.java
/** * Extracts the file name from the URL.//w w w . j a va2 s . c o m * @param url of the ftp server, includes the file to upload/download * @return the filename to upload/download */ private String extractFileName(URL url) { String filename = url.getFile(); if (filename.endsWith(";type=i") || filename.endsWith(";type=a")) { filename = filename.substring(0, filename.length() - 7); } return filename; }
From source file:com.navercorp.pinpoint.bootstrap.java9.module.JarFileAnalyzerTest.java
@Test public void providers() throws IOException { // Jar//from www.j a v a 2s . c om // org.apache.commons.logging.LogFactory=[org.apache.commons.logging.impl.SLF4JLogFactory] URL url = CodeSourceUtils.getCodeLocation(LogFactory.class); JarFile jarFile = new JarFile(url.getFile()); PackageAnalyzer analyzer = new JarFileAnalyzer(jarFile); PackageInfo analyze = analyzer.analyze(); List<Providers> providers = analyze.getProviders(); Providers first = providers.get(0); Assert.assertEquals(first.getService(), "org.apache.commons.logging.LogFactory"); Assert.assertTrue(first.getProviders().contains("org.apache.commons.logging.impl.SLF4JLogFactory")); }
From source file:eu.seaclouds.platform.dashboard.proxy.MonitorProxyTest.java
@Test public void testListMonitoringRules() throws Exception { URL resource = Resources.getResource(TestFixtures.MONITORING_RULES_PATH); String xml = FileUtils.readFileToString(new File(resource.getFile())); getMockWebServer().enqueue(new MockResponse().setBody(xml).setHeader("Accept", MediaType.APPLICATION_XML) .setHeader("Content-Type", MediaType.APPLICATION_XML)); assertEquals(ObjectMapperHelpers.XmlToObject(xml, MonitoringRules.class), getProxy().listMonitoringRules()); }
From source file:com.github.wesoly.happy.builder.generator.writer.AbstractWiterTest.java
public void setUp() throws Exception { URL url = this.getClass().getResource("/testBuilderClass.txt"); assertThat(url).isNotNull();//from ww w . ja v a 2 s . c o m File testBuilder = new File(url.getFile()); expectedTestBuilder = FileUtils.readFileToString(testBuilder); expectedTestBuilderNorm = normalize(expectedTestBuilder); }
From source file:com.autentia.wuija.etl.readers.CsvFileReaderTest.java
public void readCsv(String csvFile) throws FileNotFoundException, IOException { URL path = ClassLoader.getSystemResource(csvFile); List<List<String>> importRecords = csvFileReader.readCsv(path.getFile()); Assert.assertEquals("Incorrect record count", records.size(), importRecords.size()); for (int i = 0; i < records.size(); i++) { List<String> record = records.get(i); List<String> importRecord = importRecords.get(i); Assert.assertEquals("Incorrect field count for record" + i, record.size(), importRecord.size()); for (int j = 0; j < record.size(); j++) { String field = record.get(j); String importField = importRecord.get(j); Assert.assertEquals("Incorrect value for field " + j + " in record " + i, field, importField); }/*from w w w . j a v a 2 s . c o m*/ } }
From source file:com.opensymphony.xwork2.util.finder.ResourceFinder.java
private static boolean isDirectory(URL url) { String file = url.getFile(); return (file.length() > 0 && file.charAt(file.length() - 1) == '/'); }
From source file:eu.seaclouds.platform.dashboard.model.SeaCloudsApplicationDataTest.java
@BeforeMethod public void setUp() throws Exception { URL resource = Resources.getResource(TOSCA_DAM_FILE_PATH); toscaDamMap = (Map) new Yaml().load(FileUtils.openInputStream(new File(resource.getFile()))); }
From source file:util.connection.AnonymousClient.java
public String download(URL source) throws IOException { // set the request URL URL request = new URL(source, source.getFile(), handler); // send request and receive response log.info("download (start) from source=" + source); URLConnection connection = request.openConnection(); connection.setDoOutput(true);/*from w w w . j a va 2 s .c om*/ connection.setDoInput(true); connection.setUseCaches(false); connection.setAllowUserInteraction(false); connection.connect(); String responsebody = IOUtils.toString(connection.getInputStream(), "UTF-8"); // read the response netLayer.clear(); netLayer.waitUntilReady(); return responsebody; }
From source file:com.tera.common.configuration.properties.CPropertyLoader.java
/** * @param url//from w ww .j a v a 2s. co m * @return * @throws IOException */ private Properties loadPropertiesFromURL(URL url) throws IOException { log.info("Loading properties from URL: {}", url.getFile()); Properties properties = new Properties(); properties.load(url.openStream()); fillPropertiesMap(properties); return properties; }
From source file:gemlite.core.internal.support.hotdeploy.scanner.ScannerIterator.java
public ScannerIterator(URL url) throws IOException, URISyntaxException { if (url.getProtocol().equals("http") || url.getFile().endsWith(".jar")) { jarFile = true;/* w ww. j a va2 s . c om*/ jarInputStream = new JarInputStream(url.openStream()); } else { Collection<File> colls = FileUtils.listFiles(new File(url.toURI()), new String[] { class_suffix.substring(1) }, true); classFileIterator = colls.iterator(); classpathLen = url.getFile().length(); } }