List of usage examples for java.io File separatorChar
char separatorChar
To view the source code for java.io File separatorChar.
Click Source Link
From source file:de.perdoctus.ebikeconnect.gui.cdi.ConfigurationProducer.java
@Produces public Configuration createConfiguration() throws Exception { if (!settingsPath.exists() && !settingsPath.mkdirs()) { final IOException exception = new IOException( "Could not create settings file in " + settingsPath.getAbsolutePath()); logger.error(exception.getMessage(), exception); throw exception; }//from w w w .j av a 2s .co m final File configFile = new File(settingsPath.getAbsolutePath() + File.separatorChar + "settings"); if (!configFile.exists() && !configFile.createNewFile()) { final IOException exception = new IOException( "Could not create settings file in " + configFile.getAbsolutePath()); logger.error(exception.getMessage(), exception); throw exception; } final Configurations configurations = new Configurations(); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = configurations .propertiesBuilder(configFile); builder.setAutoSave(true); return builder.getConfiguration(); }
From source file:com.flexive.core.storage.binary.FxBinaryUtils.java
/** * Get the transit directory for the current node * * @return transit directory for the current node *///from ww w. ja v a 2 s . co m public static String getTransitDirectory() { String cacheDir = (String) FxContext.get().getAttribute(CTX_TRANSIT_DIR); if (cacheDir != null) return cacheDir; String path; try { path = EJBLookup.getConfigurationEngine().get(SystemParameters.NODE_TRANSIT_PATH); } catch (FxApplicationException e) { if (!e.isMessageLogged()) { LOG.error("Failed to get binary transit path: " + e.getMessage(), e); } path = "~" + File.separatorChar + "flexive" + File.separatorChar + "transit"; } File dir = new File(FxFileUtils.expandPath(path)); if (!dir.exists() && !dir.mkdirs()) { LOG.error("Could not create directory: " + dir.getAbsolutePath()); } FxContext.get().setAttribute(CTX_TRANSIT_DIR, dir.getAbsolutePath()); return dir.getAbsolutePath(); }
From source file:com.bc.util.io.FileUtils.java
/** * Returns a system dependent slashified path. * * @param path the path to shlashify/*from w w w. j a va2 s .c o m*/ * @return a system dependent slashified path. */ public static String slashify(final String path) { final char sep = File.separatorChar; if ('/' == sep) { return path.replace('\\', sep); } else { return path.replace('/', sep); } }
From source file:lux.solr.AppServerComponent.java
@Override public void prepare(ResponseBuilder rb) throws IOException { SolrQueryRequest req = rb.req;// www . j a v a 2 s . c o m SolrParams params = req.getParams(); if (rb.getQueryString() == null) { queryPath = rb.req.getParams().get(LUX_XQUERY); if (!StringUtils.isBlank(queryPath)) { String baseUri; String contextBase = (String) params.get("lux.serverBaseUri"); if (params.get("lux.baseUri") != null) { baseUri = (String) params.get("lux.baseUri"); } else if (params.get("lux.serverBaseUri") != null) { baseUri = contextBase; } else { baseUri = ""; } if (File.separatorChar == '\\') { baseUri = baseUri.replace('\\', '/'); } if (!baseUri.endsWith("/")) { // add trailing slash baseUri = baseUri + '/'; } if (baseUri.startsWith("/") || (File.separatorChar == '\\' && baseUri.matches("^[A-Za-z]:/.*$"))) { baseUri = "file://" + baseUri; } //System.out.println ("BASE URI = " + baseUri); String resourceBase = null; if (baseUri.startsWith(RESOURCE_SCHEME)) { resourceBase = baseUri.substring(RESOURCE_SCHEME.length()); } else if (baseUri.startsWith(CONTEXT_SCHEME)) { baseUri = contextBase + baseUri.substring(CONTEXT_SCHEME.length()); } String contents = null; if (resourceBase != null) { InputStream in = AppServerComponent.class.getResourceAsStream(resourceBase + queryPath); queryPath = baseUri + queryPath; if (in == null) { throw new SolrException(ErrorCode.NOT_FOUND, queryPath + " not found"); } else { try { contents = IOUtils.toString(in); } catch (IOException e) { LoggerFactory.getLogger(AppServerComponent.class) .error("An error occurred while reading " + queryPath, e); } IOUtils.closeQuietly(in); } } else { // url provided with scheme queryPath = baseUri + queryPath; URL url = new URL(queryPath); String scheme = url.getProtocol(); if (scheme.equals("lux")) { // TODO implement lux: uri resolution throw new SolrException(ErrorCode.NOT_FOUND, queryPath + " not found (actually lux: scheme is not implemented)"); } else { InputStream in = null; try { if (url.getProtocol().equals("file")) { File f = new File(url.getPath()); if (!f.exists()) { throw new SolrException(ErrorCode.NOT_FOUND, f + " not found"); } if (f.isDirectory() || !f.canRead()) { throw new SolrException(ErrorCode.FORBIDDEN, "access to " + f + " denied by rule"); } in = new FileInputStream(f); } else { // in = url.openStream(); LoggerFactory.getLogger(AppServerComponent.class) .error("URL scheme not supported: " + url.getProtocol()); } contents = IOUtils.toString(in); } catch (IOException e) { LoggerFactory.getLogger(AppServerComponent.class) .error("An error occurred while reading " + url, e); } if (in != null) { IOUtils.closeQuietly(in); } } } rb.setQueryString(contents); } } super.prepare(rb); }
From source file:com.igormaznitsa.jcp.AbstractSpyPreprocessorContextTest.java
protected String getCurrentTestFolder() { final String testFolder = FilenameUtils.normalizeNoEndSeparator(System.getProperty("test.folder")); final String fullClassPath = this.getClass().getName().replace('.', File.separatorChar); return FilenameUtils.normalize(testFolder + File.separator + fullClassPath.substring(0, fullClassPath.lastIndexOf(File.separatorChar))); }
From source file:la.alsocan.symbiot.access.DriverDao.java
public DriverDao(ObjectMapper om) { // open drivers folder String jarFolder;//from w w w .j ava 2 s .c o m try { URL url = getClass().getProtectionDomain().getCodeSource().getLocation(); File jarFile = new File(url.toURI()); jarFolder = jarFile.getParentFile().getPath(); } catch (URISyntaxException ex) { jarFolder = "<unable to resolve>"; } String driverFolderPath = jarFolder + File.separatorChar + DRIVER_FOLDER_NAME; File folder = new File(driverFolderPath); if (!folder.exists() || !folder.isDirectory()) { throw new IllegalStateException("Could not find folder '" + driverFolderPath + "'"); } // load drivers in memory drivers = new LinkedHashMap<>(); for (File file : folder.listFiles((File dir, String name) -> { return name.endsWith(".json"); })) { DriverTo to; try { to = om.readValue(file, DriverTo.class); if (!drivers.containsKey(to.getId())) { drivers.put(to.getId(), to); } else { LOG.warn("The driver file '" + file.getName() + "' uses a conflicting ID '" + to.getId() + "'"); LOG.info("Check driver with name '" + drivers.get(to.getId()).getName() + "' to resolve conflict"); LOG.info("Driver file '" + file.getName() + "' will not be loaded"); } } catch (IOException ex) { LOG.warn("Malformed driver '" + file.getName() + "': " + ex.getMessage()); LOG.info("Driver '" + file.getName() + "' will not be loaded"); } } }
From source file:hu.bme.mit.sette.common.util.JavaFileUtils.java
/** * Converts a filename to a Java class name by transliterating the file * separator characters to the package separator character. * * @param filename/* w ww . ja v a 2 s . co m*/ * The filename (e.g. hu/bme/mit/sette/MyClass.java) * @return The class name (e.g. hu.bme.mit.sette.MyClass) */ public static String filenameToClassName(final String filename) { return StringUtils.replaceChars(FilenameUtils.removeExtension(filename), File.separatorChar, JavaFileUtils.PACKAGE_SEPARATOR); }
From source file:com.linkage.utils.wsdl.support.UrlWsdlLoader.java
/** * function building XmlObject/*from w w w . ja va2s .c om*/ */ public XmlObject load(String url, XmlOptions option) throws XmlException, IOException, Exception { XmlObject object = null; if (!PathUtils.isHttpPath(url)) { try { File file = new File(url.replace('/', File.separatorChar)); if (file.exists()) url = file.toURI().toURL().toString(); } catch (Exception e) { } } if (wsdlcache.containsKey(url)) { return wsdlcache.get(url); } if (url.startsWith("file:")) { object = load(handleFile(url), option); wsdlcache.put(url, object); return object; } else if (url.startsWith("http:")) { log.debug("Getting wsdl component from [" + url + "]"); // HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); getMethod = new GetMethod(url); client.executeMethod(getMethod); byte[] content = getMethod.getResponseBody(); getMethod.releaseConnection(); object = load(new ByteArrayInputStream(content), option); wsdlcache.put(url, object); return object; } else { return object; } }
From source file:org.openmeetings.app.documents.GeneratePDF.java
public HashMap<String, HashMap<String, String>> convertPDF(String current_dir, String fileName, String fileExt, String roomName, boolean fullProcessing, String completeName) throws Exception { HashMap<String, HashMap<String, String>> returnError = new HashMap<String, HashMap<String, String>>(); HashMap<String, String> processPDF = new HashMap<String, String>(); processPDF.put("process", "processPDF"); String working_imgdir = current_dir + OpenmeetingsVariables.UPLOAD_DIR + File.separatorChar + roomName + File.separatorChar; String working_pptdir = current_dir + OpenmeetingsVariables.UPLOAD_TEMP_DIR + File.separatorChar + roomName + File.separatorChar; String fileFullPath = working_pptdir + fileName + fileExt; String destinationFolder = working_imgdir + fileName; File f = new File(destinationFolder + File.separatorChar); if (f.exists()) { int recursiveNumber = 0; String tempd = destinationFolder + "_" + recursiveNumber; while (f.exists()) { recursiveNumber++;//from w w w . j a va2 s .co m tempd = destinationFolder + "_" + recursiveNumber; f = new File(tempd); } destinationFolder = tempd; } boolean b = f.mkdir(); if (!b) { processPDF.put("error", "convertPDF + ERROR: Folder could not create " + f.getAbsolutePath()); processPDF.put("exitValue", "-1"); } else { processPDF.put("exitValue", "0"); } returnError.put("processPDF", processPDF); String outputfolder = destinationFolder + File.separatorChar; destinationFolder = destinationFolder + File.separatorChar; log.debug("fullProcessing: " + fullProcessing); if (fullProcessing) { HashMap<String, String> processOpenOffice = doJodConvert(current_dir, fileFullPath, destinationFolder, fileName); returnError.put("processOpenOffice", processOpenOffice); HashMap<String, String> processThumb = generateThumbs.generateBatchThumb(current_dir, destinationFolder + fileName + ".pdf", destinationFolder, 80, "thumb"); returnError.put("processThumb", processThumb); HashMap<String, String> processSWF = generateSWF.generateSwf(current_dir, destinationFolder, destinationFolder, fileName); returnError.put("processSWF", processSWF); } else { log.debug("-- generateBatchThumb --"); HashMap<String, String> processThumb = generateThumbs.generateBatchThumb(current_dir, fileFullPath, destinationFolder, 80, "thumb"); returnError.put("processThumb", processThumb); HashMap<String, String> processSWF = generateSWF.generateSwf(current_dir, (new File(fileFullPath)).getParentFile().getAbsolutePath() + File.separatorChar, destinationFolder, fileName); returnError.put("processSWF", processSWF); } // now it should be completed so copy that file to the expected location File fileToBeMoved = new File(completeName + fileExt); File fileWhereToMove = new File(outputfolder + fileName + fileExt); fileWhereToMove.createNewFile(); FileHelper.moveRec(fileToBeMoved, fileWhereToMove); if (fullProcessing) { HashMap<String, String> processXML = CreateLibraryPresentation.getInstance() .generateXMLDocument(outputfolder, fileName + fileExt, fileName + ".pdf", fileName + ".swf"); returnError.put("processXML", processXML); } else { HashMap<String, String> processXML = CreateLibraryPresentation.getInstance() .generateXMLDocument(outputfolder, fileName + fileExt, null, fileName + ".swf"); returnError.put("processXML", processXML); } return returnError; }
From source file:de.egore911.versioning.deployer.performer.PerformCheckout.java
private static void performGit(String target, String url) { String tmp = target + File.separatorChar + "checkout"; try {//from ww w. ja v a2 s .c o m File tmpDir = new File(tmp); try { if (!new File(tmp + "/.git").exists()) { Git.cloneRepository().setURI(url).setDirectory(tmpDir).call(); } else { FileRepository fileRepository = new FileRepository(tmp + "/.git"); Git git = new Git(fileRepository); git.pull().setRebase(true).call(); } FileUtils.copyDirectory(tmpDir, new File(target)); } finally { FileUtils.deleteDirectory(tmpDir); } } catch (GitAPIException | IOException e) { LOG.error(e.getMessage(), e); } }