List of usage examples for java.io File toURI
public URI toURI()
From source file:com.gemstone.gemfire.management.internal.cli.shell.GfshInitFileJUnitTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { saveLog4j2Config = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY); saveUserDir = System.getProperty("user.dir"); saveUserHome = System.getProperty("user.home"); julLogger = java.util.logging.Logger.getLogger(""); saveHandlers = julLogger.getHandlers(); for (Handler handler : saveHandlers) { julLogger.removeHandler(handler); }/*from w ww. ja v a 2s . co m*/ File log4j2XML = temporaryFolder_Config.newFile("log4j2.xml"); FileUtils.writeStringToFile(log4j2XML, "<Configuration/>", APPEND); System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, log4j2XML.toURI().toString()); }
From source file:fr.paris.lutece.plugins.swaggerui.service.SwaggerFileService.java
/** * Returns the list of swagger files/* w w w . ja v a 2s.c o m*/ * * @param request The HTTP request * @return The list of swagger files */ public static List<SwaggerFile> getSwaggerFiles(HttpServletRequest request) { List<SwaggerFile> listSwaggerFiles = new ArrayList<>(); List<File> listSwaggerDirectories = new ArrayList<>(); String[] filesExtension = { EXT_JSON, EXT_YAML }; File folderWebApp = new File(AppPathService.getWebAppPath() + SWAGGER_DIRECTORY_PATH); findDirectory(listSwaggerDirectories, folderWebApp); for (File swaggerDirectory : listSwaggerDirectories) { Collection<File> filesSwagger = FileUtils.listFiles(swaggerDirectory, filesExtension, true); for (File fileSwagger : filesSwagger) { String strPluginName = swaggerDirectory.getParentFile().getParentFile().getName(); if (PluginService.isPluginEnable(strPluginName)) { SwaggerFile swaggerFile = new SwaggerFile(); swaggerFile.setPluginName(strPluginName); swaggerFile.setVersion(fileSwagger.getParentFile().getName()); String relativePath = new File(AppPathService.getWebAppPath()).toURI() .relativize(fileSwagger.toURI()).getPath(); swaggerFile.setPath(AppPathService.getBaseUrl(request) + SERVLET_PATH + relativePath); listSwaggerFiles.add(swaggerFile); } } } return listSwaggerFiles; }
From source file:com.all.client.components.AllMediaProviderImpl.java
private static final URI createURI(File soundFile) throws URISyntaxException { URI fileURI;/* w ww. j av a 2s.c o m*/ if (Environment.isWindows()) { String shortPath = ShortFilePathNative.getShortPath(soundFile); String filePath = "file:/" + shortPath.replaceAll("\\\\", "/"); fileURI = new URI(soundFile.toURI().toASCIIString()); log.debug("media file path " + filePath); } else { fileURI = soundFile.toURI(); } return fileURI; }
From source file:com.pieframework.model.repository.ModelStore.java
/** * @param xmlFile/*from w w w. j av a2 s . co m*/ * @param writer * @throws ParserConfigurationException * @throws SAXException * @throws IOException * @throws TransformerException */ protected static void processXIncludes(File xmlFile, Writer writer) throws ParserConfigurationException, SAXException, IOException, TransformerException { final InputStream xml = new FileInputStream(xmlFile); // This sets the base where XIncludes are resolved InputSource i = new InputSource(xml); i.setSystemId(xmlFile.toURI().toString()); // Configure Document Builder DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setXIncludeAware(true); factory.setNamespaceAware(true); factory.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false); DocumentBuilder docBuilder = factory.newDocumentBuilder(); if (!docBuilder.isXIncludeAware()) { throw new IllegalStateException(); } // Parse the InputSource Document doc = docBuilder.parse(i); // output Source source = new DOMSource(doc); Result result = new StreamResult(writer); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(source, result); }
From source file:com.t_oster.visicut.misc.Helper.java
/** * Generates an HTML img-Tag for the given file with given size * @param f/*from ww w . j a v a2 s . c o m*/ * @param width * @param height * @return */ public static String imgTag(File f, int width, int height) { try { return imgTag(f.toURI().toURL(), width, height); } catch (MalformedURLException ex) { Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex); String size = width > 0 && height > 0 ? "width=" + width + " height=" + height : ""; return "<img " + size + " src=\"file://" + f.getAbsolutePath() + "\"/>"; } }
From source file:edu.uci.ics.asterix.event.service.AsterixEventServiceUtil.java
private static void injectAsterixLogPropertyFile(String asterixInstanceDir, AsterixInstance asterixInstance) throws IOException, EventException { final String asterixJarPath = asterixJarPath(asterixInstance, asterixInstanceDir); File sourceJar1 = new File(asterixJarPath); Properties txnLogProperties = new Properties(); URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { sourceJar1.toURI().toURL() }); InputStream in = urlClassLoader.getResourceAsStream(TXN_LOG_CONFIGURATION_FILE); if (in != null) { txnLogProperties.load(in);/* w w w .j a v a2 s . c o m*/ } writeAsterixLogConfigurationFile(asterixInstance, txnLogProperties); File sourceJar2 = new File(asterixJarPath); File replacementFile = new File(asterixInstanceDir + File.separator + "log.properties"); replaceInJar(sourceJar2, TXN_LOG_CONFIGURATION_FILE, replacementFile); new File(asterixInstanceDir + File.separator + "log.properties").delete(); }
From source file:org.wso2.carbon.bpel.core.ode.integration.utils.AxisServiceUtils.java
private static AxisService populateAxisService(BPELProcessProxy processProxy, AxisConfiguration axisConfiguration, WSDL11ToAxisServiceBuilder serviceBuilder) throws AxisFault { ProcessConf pConf = processProxy.getProcessConfiguration(); AxisService axisService = serviceBuilder.populateService(); axisService.setParent(axisConfiguration); axisService.setWsdlFound(true);//w w w. j a v a 2 s . c om axisService.setCustomWsdl(true); axisService.setClassLoader(axisConfiguration.getServiceClassLoader()); URL wsdlUrl = null; for (File file : pConf.getFiles()) { if (file.getAbsolutePath().indexOf(processProxy.getWsdlDefinition().getDocumentBaseURI()) > 0) { try { wsdlUrl = file.toURI().toURL(); } catch (MalformedURLException e) { String errorMessage = "Cannot convert File URI to URL."; handleException(pConf.getProcessId(), errorMessage, e); } } } if (wsdlUrl != null) { axisService.setFileName(wsdlUrl); } Utils.setEndpointsToAllUsedBindings(axisService); axisService.addParameter(new Parameter("useOriginalwsdl", "true")); axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true")); axisService.addParameter(new Parameter("setEndpointsToAllUsedBindings", "true")); /* Setting service type to use in service management*/ axisService.addParameter(ServerConstants.SERVICE_TYPE, "bpel"); /* Process ID as a service parameter to use with process try-it*/ axisService.addParameter(BPELConstants.PROCESS_ID, pConf.getProcessId()); /* Fix for losing of security configuration when updating BPEL package*/ axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true")); // axisService.addParameter( // new Parameter(BPELConstants.MESSAGE_RECEIVER_INVOKE_ON_SEPARATE_THREAD, "true")); return axisService; }
From source file:com.puppycrawl.tools.checkstyle.utils.CommonUtil.java
/** * Resolve the specified filename to a URI. * @param filename name os the file//w w w. j av a2 s.c om * @return resolved header file URI * @throws CheckstyleException on failure */ public static URI getUriByFilename(String filename) throws CheckstyleException { // figure out if this is a File or a URL URI uri; try { final URL url = new URL(filename); uri = url.toURI(); } catch (final URISyntaxException | MalformedURLException ignored) { uri = null; } if (uri == null) { final File file = new File(filename); if (file.exists()) { uri = file.toURI(); } else { // check to see if the file is in the classpath try { final URL configUrl = CommonUtil.class.getResource(filename); if (configUrl == null) { throw new CheckstyleException(UNABLE_TO_FIND_EXCEPTION_PREFIX + filename); } uri = configUrl.toURI(); } catch (final URISyntaxException ex) { throw new CheckstyleException(UNABLE_TO_FIND_EXCEPTION_PREFIX + filename, ex); } } } return uri; }
From source file:com.serotonin.m2m2.Main.java
private static void loadLib(File module, List<URL> urls) throws Exception { File[] jarFiles = new File(module, "lib").listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); }//from ww w.j av a2 s. c o m }); if ((jarFiles == null) || (jarFiles.length == 0)) { return; } for (File file : jarFiles) { if (!file.isFile()) continue; urls.add(file.toURI().toURL()); } }
From source file:com.net2plan.gui.GUINet2Plan.java
private static void loadHelp() { File helpFile = new File(SystemUtils.getCurrentDir() + SystemUtils.getDirectorySeparator() + "doc" + SystemUtils.getDirectorySeparator() + "help" + SystemUtils.getDirectorySeparator() + USERSGUIDEFILENAME);/*from w w w . j av a 2 s. c o m*/ try { HTMLUtils.browse(helpFile.toURI()); } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Unable to show the User's guide. Please, visit http://www.net2plan.com for the latest version", "Error showing User's guide"); } }