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:dynamicrefactoring.domain.TestImport.java
/** * Comprueba que el proceso de importacin de la refactorizacin dinmica * Rename Class a partir de un directorio temporal "./temp" se ha realizado * correctamente.//www.ja v a2s .c om * * @throws XMLRefactoringReaderException * XMLRefactoringReaderException. * @throws IOException * IOException. */ @Test public void testImportRefactoring() throws XMLRefactoringReaderException, IOException { // Eliminamos alguno de los ficheros .class requeridos por dicha // refactorizacin para // comprobar que tras la importacin esos ficheros se encuentran donde // deben final String renameClassFile = getMoonRefactoryDir() + "concreteaction" + File.separatorChar + "RenameClass.class"; final String notExistsClassWithNameClassFile = getMoonRefactoryDir() + "concretepredicate" + File.separatorChar + "NotExistsClassWithName.class"; FileManager.deleteFile(renameClassFile); FileManager.deleteFile(notExistsClassWithNameClassFile); RefactoringCatalogStub catalog = new RefactoringCatalogStub(); // Importamos la refactorizacin ExportImportUtilities.importRefactoring( FilenameUtils.separatorsToSystem(".\\temp\\Rename Class\\Rename Class.xml"), false, catalog); assertTrue(catalog.hasRefactoring("Rename Class")); }
From source file:com.thoughtworks.go.util.FileUtil.java
public static String[] dissect(String path) { char sep = File.separatorChar; path = path.replace('/', sep).replace('\\', sep); // make sure we are dealing with an absolute path if (!isAbsolutePath(path)) { throw new RuntimeException(path + " is not an absolute path"); }//ww w . j a v a2 s. com String root; int colon = path.indexOf(':'); if (colon > 0 && (ON_DOS || ON_NETWARE)) { int next = colon + 1; root = path.substring(0, next); char[] ca = path.toCharArray(); root += sep; //remove the initial separator; the root has it. next = (ca[next] == sep) ? next + 1 : next; StringBuilder sbPath = new StringBuilder(); // Eliminate consecutive slashes after the drive spec: for (int i = next; i < ca.length; i++) { if (ca[i] != sep || ca[i - 1] != sep) { sbPath.append(ca[i]); } } path = sbPath.toString(); } else if (path.length() > 1 && path.charAt(1) == sep) { // UNC drive int nextsep = path.indexOf(sep, 2); nextsep = path.indexOf(sep, nextsep + 1); root = (nextsep > 2) ? path.substring(0, nextsep + 1) : path; path = path.substring(root.length()); } else { root = File.separator; path = path.substring(1); } return new String[] { root, path }; }
From source file:it.polimi.diceH2020.launcher.controller.rest.DownloadsController.java
private void downloadSM(List<SimulationsManager> smList, HttpServletResponse response) { Map<String, String> files = new HashMap<>(); for (SimulationsManager manager : smList) { String folder = manager.getFolder(); List<InteractiveExperiment> intExpList = manager.getExperimentsList(); for (InteractiveExperiment anIntExpList : intExpList) { if (anIntExpList != null) { if (anIntExpList.getState().equals(States.COMPLETED)) { files.put(/*from w ww.j a va 2s . c o m*/ "results" + File.separatorChar + folder + File.separatorChar + manager.getId() + File.separatorChar + anIntExpList.getInstanceName() + ".json", anIntExpList.getFinalSolution()); } } } List<Map<String, String>> inputFiles = retrieveInputFiles(manager); files.put("input" + File.separatorChar + folder + File.separatorChar + manager.getInputFileName(), manager.getInput()); for (Map<String, String> inputFile : inputFiles) { files.put("input" + File.separatorChar + folder + File.separatorChar + inputFile.get("name"), inputFile.get("content")); } } respondWithZipFile(files, response); }
From source file:com.util.FileService.java
/** * Get case file location/*w w w . java2s . co m*/ * * @param item RelatedCaseModel * @return String file path */ public static String getCaseFolderLocationRelatedCase(RelatedCaseModel item) { return Global.getActivityPath() + File.separatorChar + NumberFormatService.getSection(item.getCaseType()) + File.separatorChar + item.getCaseYear() + File.separatorChar + NumberFormatService.FullCaseNumber(item) + File.separatorChar; }
From source file:edu.stanford.epadd.launcher.Splash.java
private static Context deployWarAt(String warName, String path) throws IOException, ServletException { // extract the war to tmpdir final URL warUrl = TomcatMain.class.getClassLoader().getResource(warName); if (warUrl == null) { out.println("Sorry! Unable to locate file on classpath: " + warName); return null; }// w w w.j av a2 s .com InputStream is = warUrl.openStream(); String tmp = System.getProperty("java.io.tmpdir"); String file = tmp + File.separatorChar + warName; out.println("Extracting: " + warName + " to " + file + " is=" + is); File existingFile = new File(file); if (existingFile.exists()) out.println("Existing file: " + file); // if (new File(file).exists()) copy_stream_to_file(is, file); File newFile = new File(file); if (!newFile.exists()) { out.println("Sorry! Unable to copy war file: " + file); return null; } out.println( "Copied muse war file with size " + newFile.length() + " bytes to " + newFile.getAbsolutePath()); // clear the tomcat workdir which unfortunately caches jsp-generated java files sometimes and leads to terribly insiduous bugs. String workDir = tmp + File.separator + "muse" + File.separator + "working"; File workFile = new File(workDir); if (workFile.exists()) { out.println("Tomcat work dir exists: " + workDir); boolean success = deleteDir(new File(workDir)); if (!success) out.println("Warning: unable to clear tomcat work dir " + workDir); else out.println("Cool... able to clear tomcat work dir " + workDir); } else out.println("Good, tomcat work dir does not already exist: " + workDir); return server.addWebapp(path, new File(file).getAbsolutePath()); }
From source file:org.openmeetings.app.documents.GenerateImage.java
public HashMap<String, HashMap<String, String>> convertImageUserProfile(String current_dir, String fileName, String fileExt, Long users_id, String fileNameShort, boolean fullProcessing) throws Exception { HashMap<String, HashMap<String, String>> returnMap = new HashMap<String, HashMap<String, String>>(); String working_imgdir = current_dir + OpenmeetingsVariables.UPLOAD_DIR + File.separatorChar + "profiles" + File.separatorChar + ScopeApplicationAdapter.profilesPrefix + users_id + File.separatorChar; String working_pptdir = current_dir + OpenmeetingsVariables.UPLOAD_TEMP_DIR + File.separatorChar + "profiles" + File.separatorChar + ScopeApplicationAdapter.profilesPrefix + users_id + File.separatorChar; String fileFullPath = working_pptdir + fileName + fileExt; File f = new File(working_imgdir + fileName + fileExt); if (f.exists()) { int recursiveNumber = 0; String tempd = fileName + "_" + recursiveNumber; while (f.exists()) { recursiveNumber++;// w w w . ja va2 s . com tempd = fileName + "_" + recursiveNumber; f = new File(working_imgdir + tempd + fileExt); } fileName = tempd; } String destinationFile = working_imgdir + fileName; HashMap<String, String> processJPG = this.convertSingleJpg(fileFullPath, destinationFile); HashMap<String, String> processThumb1 = generateThumbs.generateThumb("_chat_", current_dir, destinationFile, 40); HashMap<String, String> processThumb2 = generateThumbs.generateThumb("_profile_", current_dir, destinationFile, 126); HashMap<String, String> processThumb3 = generateThumbs.generateThumb("_big_", current_dir, destinationFile, 240); returnMap.put("processJPG", processJPG); returnMap.put("processThumb1", processThumb1); returnMap.put("processThumb2", processThumb2); returnMap.put("processThumb3", processThumb3); // Delete old one File fToDelete = new File(fileFullPath); fToDelete.delete(); File fileNameToStore = new File(destinationFile + ".jpg"); String pictureuri = fileNameToStore.getName(); Users us = usersDao.getUser(users_id); us.setUpdatetime(new java.util.Date()); us.setPictureuri(pictureuri); usersDao.updateUser(us); //FIXME: After uploading a new picture all other clients should refresh //scopeApplicationAdapter.updateUserSessionObject(users_id, pictureuri); return returnMap; }
From source file:AIR.ResourceBundler.Console.ResourcesBuilder.java
private void writeFileInput(FileWriter sw, FileSetInput fileInput) throws IOException { FileSet fileSet = fileInput.getParent(); if (StringUtils.isEmpty(fileInput.getPath())) { throw new FileNotFoundException("No file path defined for the input " + fileSet.getName()); }//from w w w.j av a 2 s . c o m // get file info String filePath = Path.combine(_parentFolder, fileInput.getPath()); filePath = filePath.replace('/', File.separatorChar); String fileName = Path.getFileName(fileInput.getPath()); if (StringUtils.isEmpty(fileName)) { throw new IOException(String.format("Could not find the file name in the path \"%s\".", filePath)); } // write out file header writeFileHeader(sw, filePath); writePrepend(sw, fileInput); // read input file try (BufferedReader sr = new BufferedReader(new FileReader(filePath))) { boolean compressed = false; // check if we can compress this resource group if (fileSet.isCompress()) { String fileExt = Path.getExtension(fileName).toLowerCase(); // check if this file supports compression if ("js".equals(fileExt)) { compressJS(sw, sr, fileSet); compressed = true; } } // if no compression was performed then add the file as is if (!compressed) { String line; while ((line = sr.readLine()) != null) { sw.write(line + "\n"); } } writeAppend(sw, fileInput); sw.write("\n"); } }
From source file:com.eviware.soapui.support.Tools.java
public static String ensureFileDir(String file, String basedir) { if (file == null || file.length() == 0) { return ""; }//w w w.jav a 2 s . com File dirFile = new File(basedir, file); if (!dirFile.isAbsolute()) { if (basedir.length() == 0) { basedir = new File("").getAbsolutePath(); } dirFile = new File(basedir, file); } String absolutePath = dirFile.getAbsolutePath(); if (!dirFile.exists()) { int ix = absolutePath.lastIndexOf(File.separatorChar); File fileDir = new File(absolutePath.substring(0, ix)); fileDir.mkdirs(); } return absolutePath; }
From source file:com.github.mbenson.privileged.weaver.FilesystemWeaver.java
/** * Clear the way by deleting classfiles woven with a different * {@link Policy}.//from w w w. ja v a 2s. c o m * * @throws NotFoundException */ public void prepare() throws NotFoundException { info("preparing %s; policy = %s", target, policy); final Set<File> toDelete = new TreeSet<File>(); for (final Class<?> type : getDeclaringClasses(findPrivilegedMethods())) { final CtClass ctClass = classPool.get(type.getName()); final String policyValue = toString(ctClass.getAttribute(generateName(POLICY_NAME))); if (policyValue == null || policyValue.equals(policy.name())) { continue; } debug("class %s previously woven with policy %s", type.getName(), policyValue); final File packageDir = new File(target, StringUtils.replaceChars(ctClass.getPackageName(), '.', File.separatorChar)); // simple classname of outermost class, plus any inner classes: final String pattern = new StringBuilder(getOutermost(type).getSimpleName()).append("(\\$.+)??\\.class") .toString(); debug("searching %s for pattern '%s'", packageDir.getAbsolutePath(), pattern); toDelete.addAll(FileUtils.listFiles(packageDir, new RegexFileFilter(pattern), null)); } if (toDelete.isEmpty()) { return; } info("Deleting %s files...", toDelete.size()); debug(toDelete.toString()); for (File f : toDelete) { if (!f.delete()) { debug("Failed to delete %s", f); } } }
From source file:com.silverpeas.util.web.servlet.FileUploadUtilTest.java
@Test public void testConvertPathToServerOS() throws Exception { String fileName = FileUtil.convertPathToServerOS( "C:\\Documents and Settings\\rivoirede\\Bureau\\GED KHOLER\\import_kohler_partiel.xml"); if (File.separatorChar == '/') { assertThat(fileName,/* w w w . j a v a 2 s.c o m*/ is("C:/Documents and Settings/rivoirede/Bureau/GED KHOLER/import_kohler_partiel.xml")); } else { assertThat(fileName, is("C:\\Documents and Settings\\rivoirede\\Bureau\\GED KHOLER\\import_kohler_partiel.xml")); } fileName = FileUtil.convertPathToServerOS("/home/silverpeas/test/result.txt"); if (File.separatorChar == '/') { assertThat(fileName, is("/home/silverpeas/test/result.txt")); } else { assertThat(fileName, is("\\home\\silverpeas\\test\\result.txt")); } }