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.thischwa.pmcms.tool.file.FileComparator.java
@Override public int compare(final File f1, final File f2) { if (f1.getAbsolutePath().equals(f2.getAbsolutePath())) return 0; String path1 = FilenameUtils.getFullPath(f1.getAbsolutePath()); String path2 = FilenameUtils.getFullPath(f2.getAbsolutePath()); String name1 = FilenameUtils.getName(f1.getAbsolutePath()); String name2 = FilenameUtils.getName(f2.getAbsolutePath()); if (path1.equals(path2) || (StringUtils.isBlank(path1) && StringUtils.isBlank(path2))) return name1.compareTo(name2); String[] pathParts1 = StringUtils.split(FilenameUtils.getFullPathNoEndSeparator(path1), File.separatorChar); String[] pathParts2 = StringUtils.split(FilenameUtils.getFullPathNoEndSeparator(path2), File.separatorChar); if (pathParts1.length < pathParts2.length) return -1; if (pathParts1.length > pathParts2.length) return +1; int i = 0;/*from w ww . j a v a 2 s.c o m*/ while (i < pathParts1.length && i < pathParts2.length) { if (!pathParts1[i].equals(pathParts2[i])) return pathParts1[i].compareTo(pathParts2[i]); i++; } return 0; }
From source file:org.openmrs.logic.rule.definition.JavaLanguageHandler.java
/** * @see CompilableLanguageHandler#prepareSource(RuleDefinition,String) *///from w w w. jav a 2 s . com public void prepareSource(RuleDefinition logicRule, String className) { AdministrationService as = Context.getAdministrationService(); String javaDirectory = as.getGlobalProperty(LogicConstants.RULE_DEFAULT_SOURCE_FOLDER); File sourceDirectory = OpenmrsUtil.getDirectoryInApplicationDataDirectory(javaDirectory); String path = className.replace('.', File.separatorChar); File javaFile = new File(sourceDirectory, path + JAVA_EXTENSION); if (!javaFile.getParentFile().exists()) javaFile.getParentFile().mkdirs(); Date modifiedDate = logicRule.getDateChanged(); if (modifiedDate == null) { modifiedDate = logicRule.getDateCreated(); } // only compile when the java file is not exist or the concept derived is updated after the source file last modified if (!javaFile.exists() || modifiedDate.after(new Date(javaFile.lastModified()))) { String content = logicRule.getRuleContent(); content = content.replace("{CLASSNAME}", className.substring(className.lastIndexOf('.') + 1)); try { BufferedWriter writer = new BufferedWriter(new FileWriter(javaFile)); writer.write(content); writer.close(); } catch (IOException e) { log.error("Failed saving java rule file ...", e); } } }
From source file:org.openmeetings.app.documents.GenerateThumbs.java
public HashMap<String, String> generateThumb(String pre, String current_dir, String filepath, Integer thumbSize) {// w ww.ja v a 2 s. com // Init variables File f = new File(filepath); String name = f.getName(); String folder = f.getParentFile().getAbsolutePath() + File.separatorChar; String[] argv = new String[] { generateImage.getPathToImageMagic(), "-thumbnail", Integer.toString(thumbSize) + "x" + Integer.toString(thumbSize), filepath + ".jpg", folder + pre + name + ".jpg" }; log.debug("START generateThumb ################# "); for (int i = 0; i < argv.length; i++) { log.debug(" i " + i + " argv-i " + argv[i]); } log.debug("END generateThumb ################# "); if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") == -1) { return ProcessHelper.executeScript("generateBatchThumbByWidth", argv); } else { return this.processImageWindows(argv); } }
From source file:hu.bme.mit.sette.common.util.JavaFileUtils.java
/** * Converts a Java package name to filename by transliterating the package * separator characters to the file separator charater. * * @param packageName/* ww w . j av a2 s. c o m*/ * The package name (e.g. hu.bme.mit.sette) * @return The filename (e.g. hu/bme/mit/sette) */ public static String packageNameToFilename(final String packageName) { return StringUtils.replaceChars(packageName, JavaFileUtils.PACKAGE_SEPARATOR, File.separatorChar); }
From source file:com.hubrick.raml.mojo.util.JavaNames.java
public static String toFilePathString(String className) { return className.replace('.', File.separatorChar) + ".java"; }
From source file:MinAppletviewer.java
public AppSupport() throws Exception { URL url = null;//from w w w. j av a 2 s .c o m String urlpart = System.getProperty("user.dir"); urlpart = urlpart.replace(File.separatorChar, '/'); url = new URL("file://" + urlpart + "/"); codeBase = documentBase = url; }
From source file:org.dspace.app.webui.cris.servlet.ResearcherPictureServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { String idString = req.getPathInfo(); String[] pathInfo = idString.split("/", 2); String authorityKey = pathInfo[1]; Integer id = ResearcherPageUtils.getRealPersistentIdentifier(authorityKey, ResearcherPage.class); if (id == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/*from w ww. j a v a2 s . c o m*/ } ResearcherPage rp = ResearcherPageUtils.getCrisObject(id, ResearcherPage.class); File file = new File(ConfigurationManager.getProperty(CrisConstants.CFG_MODULE, "researcherpage.file.path") + File.separatorChar + JDynATagLibraryFunctions.getFileFolder(rp.getPict().getValue()) + File.separatorChar + JDynATagLibraryFunctions.getFileName(rp.getPict().getValue())); InputStream is = null; try { is = new FileInputStream(file); response.setContentType(req.getSession().getServletContext().getMimeType(file.getName())); Long len = file.length(); response.setContentLength(len.intValue()); response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); FileCopyUtils.copy(is, response.getOutputStream()); response.getOutputStream().flush(); } finally { if (is != null) { IOUtils.closeQuietly(is); } } }
From source file:de.kurashigegollub.dev.gcatest.Utils.java
public static String readFileAsStringFromBundle(String filename) throws IOException { InputStream is = Utils.class.getResourceAsStream(("/" + filename).replace('/', File.separatorChar)); if (is == null) { throw new IOException(String.format("Could not find %s", filename)); }/*from w w w . j a va 2 s. c o m*/ StringWriter sw = new StringWriter(); IOUtils.copy(is, sw, "utf-8"); //this uses Apache commons io return sw.toString(); }
From source file:com.stimulus.archiva.presentation.DownloadBean.java
@Override protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String fileName = request.getParameter("attachment"); //String fileName = ((MessageBean)form).getAttachment(); //File file = new File(((MessageBean)form).getAttachmentFilePath()); String filePath = Config.getFileSystem().getViewPath() + File.separatorChar + fileName; File file = new File(filePath); logger.debug("download attachment {fileName='" + file.getPath() + "'"); String agent = request.getHeader("USER-AGENT"); if (null != agent && -1 != agent.indexOf("MSIE")) { String codedfilename = URLEncoder.encode(fileName, "UTF8"); response.setContentType("application/x-download"); response.setHeader("Content-Disposition", "attachment;filename=" + codedfilename); } else if (null != agent && -1 != agent.indexOf("Mozilla")) { String codedfilename = MimeUtility.encodeText(fileName, "UTF8", "B"); response.setContentType("application/x-download"); response.setHeader("Content-Disposition", "attachment;filename=" + codedfilename); } else {/*from w w w . ja v a2s .co m*/ response.setHeader("Content-Disposition", "attachment;filename=" + fileName); } String contentType = "application/download"; response.setContentLength((int) file.length()); Config.getFileSystem().getTempFiles().markForDeletion(file); return new FileStreamInfo(contentType, file); }
From source file:com.opengamma.language.export.WikiDocumentationExporter.java
protected String getWikiDoc(final String name, final String[] folders) { for (String folder : folders) { // TODO: if there are a lot of files, split the file system slightly final File f = new File(folder + File.separatorChar + name + ".txt"); if (f.exists()) { final StringBuilder sb = new StringBuilder(); try { final BufferedReader r = new BufferedReader(new FileReader(f)); String s = r.readLine(); while (s != null) { final String[] tokens = s.trim().split("\\s+"); if (tokens.length > 0) { if ("!inherit".equals(tokens[0])) { sb.append(getWikiDoc(name, removeFirst(folders))); s = r.readLine(); continue; } else if ("!copy".equals(tokens[0])) { for (int i = 1; i < tokens.length; i++) { if (i > 1) { sb.append('\n'); }/* www . j av a 2s . co m*/ sb.append(getWikiDoc(tokens[i], folders)); } s = r.readLine(); continue; } } sb.append(s).append('\n'); s = r.readLine(); } r.close(); } catch (IOException e) { throw new OpenGammaRuntimeException("Error building man page for " + name, e); } return sb.toString(); } } return ""; }