List of usage examples for org.apache.commons.lang3 SystemUtils PATH_SEPARATOR
String PATH_SEPARATOR
To view the source code for org.apache.commons.lang3 SystemUtils PATH_SEPARATOR.
Click Source Link
The path.separator System Property.
From source file:de.uni_koeln.spinfo.maalr.sigar.SigarWrapper.java
private static void initialize() { logger.info("Initializing..."); String libBase = "/hyperic-sigar-1.6.5/sigar-bin/lib/"; try {//from www. j av a 2 s . com String prefix = "libsigar"; if (SystemUtils.IS_OS_WINDOWS) { prefix = "sigar"; } String arch = getSystemArch(); String suffix = getSystemSuffix(); String resourceName = prefix + "-" + arch + "-" + suffix; logger.info("Native library: " + resourceName); String resource = libBase + resourceName; URL toLoad = SigarWrapper.class.getResource(resource); File home = new File(System.getProperty("user.home")); File libs = new File(home, ".maalr/libs/sigar"); libs.mkdirs(); File tmp = new File(libs, resourceName); tmp.deleteOnExit(); FileOutputStream fos = new FileOutputStream(tmp); InputStream in = toLoad.openStream(); int i; while ((i = in.read()) != -1) { fos.write(i); } in.close(); fos.close(); logger.info("Library copied to " + tmp.getAbsolutePath()); String oldPath = System.getProperty("java.library.path"); System.setProperty("java.library.path", oldPath + SystemUtils.PATH_SEPARATOR + libs.getAbsolutePath()); logger.info("java.library.path updated: " + System.getProperty("java.library.path")); executors = Executors.newScheduledThreadPool(1, new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setDaemon(true); return t; } }); logger.info("Initialization completed."); } catch (Exception e) { logger.error("Failed to initialize!", e); } }
From source file:com.norconex.commons.lang.file.FileUtil.java
/** * Moves a file to a directory. Like {@link #moveFile(File, File)}: * <ul>/*from w ww . ja va2 s . c om*/ * <li>If the target directory does not exists, it creates it first.</li> * <li>If the target file already exists, it deletes it first.</li> * <li>If target file deletion does not work, it will try 10 times, * waiting 1 second between each try to give a chance to whatever * OS lock on the file to go.</li> * <li>It throws a IOException if the move failed (as opposed to fail * silently).</li> * </ul> * @param sourceFile source file to move * @param targetDir target destination * @throws IOException cannot move file. */ public static void moveFileToDir(File sourceFile, File targetDir) throws IOException { if (sourceFile == null || !sourceFile.isFile()) { throw new IOException("Source file is not valid: " + sourceFile); } if (targetDir == null || targetDir.exists() && !targetDir.isDirectory()) { throw new IOException("Target directory is not valid:" + targetDir); } if (!targetDir.exists()) { FileUtils.forceMkdir(targetDir); } String fileName = sourceFile.getName(); File targetFile = new File(targetDir.getAbsolutePath() + SystemUtils.PATH_SEPARATOR + fileName); moveFile(sourceFile, targetFile); }
From source file:se.trixon.toolbox.checksum.ChecksumTopComponent.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { logPanel.clear();/* w ww .j a va 2 s . c om*/ if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); } } }
From source file:se.trixon.toolbox.checksum.ChecksumTopComponent.java
@Override public void onFileChooserPreSelect(FileChooserPanel fileChooserPanel) { final String[] paths = sourceChooserPanel.getPath().split(SystemUtils.PATH_SEPARATOR); File[] files = new File[paths.length]; for (int i = 0; i < files.length; i++) { files[i] = new File(paths[i]); }//from ww w.j a va 2 s. c om sourceChooserPanel.getFileChooser().setSelectedFiles(files); }
From source file:se.trixon.toolbox.checksum.ChecksumTopComponent.java
private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed SimpleDialog.setParent(openButton.getTopLevelAncestor()); if (SimpleDialog.openFileAndDirectoy(true)) { String paths = StringUtils.join(SimpleDialog.getPaths(), SystemUtils.PATH_SEPARATOR); sourceChooserPanel.setPath(paths); logPanel.clear();/*from w w w. j a v a 2 s . com*/ } }
From source file:se.trixon.toolbox.dbtext.DbTextTopComponent.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); }//from w w w .jav a 2 s. c om } }
From source file:se.trixon.toolbox.dbtext.DbTextTopComponent.java
@Override public void onFileChooserPreSelect(FileChooserPanel fileChooserPanel) { if (fileChooserPanel == sourceChooserPanel) { final String[] paths = sourceChooserPanel.getPath().split(SystemUtils.PATH_SEPARATOR); File[] files = new File[paths.length]; for (int i = 0; i < files.length; i++) { files[i] = new File(paths[i]); }// w w w .j a va2s . c o m sourceChooserPanel.getFileChooser().setSelectedFiles(files); } }
From source file:se.trixon.toolbox.dbtext.Operation.java
public Operation(OperationListener operationListener, File destination) { mListener = operationListener;//from w w w. j a va 2 s .c o m mDestinationFile = destination; mBundle = NbBundle.getBundle(DbTextTopComponent.class); mValidSourceString = mOptions.getSourcePaths().length() > 0; String[] sourcePathsAsStrings = mOptions.getSourcePaths().split(SystemUtils.PATH_SEPARATOR); mSourceFiles = new File[sourcePathsAsStrings.length]; for (int i = 0; i < sourcePathsAsStrings.length; i++) { if (SystemUtils.IS_OS_WINDOWS) { sourcePathsAsStrings[i] = StringUtils.trim(sourcePathsAsStrings[i]); } mSourceFiles[i] = new File(sourcePathsAsStrings[i]); } }
From source file:se.trixon.toolbox.photokml.config.ModuleSourcePanel.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); }//from ww w . ja va2s. c om saveSourcePath(); } }
From source file:se.trixon.toolbox.photokml.Operation.java
public Operation(OperationListener operationListener, File destination) { mListener = operationListener;// w ww .j a v a 2 s . com mDestinationFile = destination; mBundle = NbBundle.getBundle(PhotoKmlTopComponent.class); mValidSourceString = mOptions.getSourcePaths().length() > 0; String[] sourcePathsAsStrings = mOptions.getSourcePaths().split(SystemUtils.PATH_SEPARATOR); mSourceFiles = new File[sourcePathsAsStrings.length]; for (int i = 0; i < sourcePathsAsStrings.length; i++) { if (SystemUtils.IS_OS_WINDOWS) { sourcePathsAsStrings[i] = StringUtils.trim(sourcePathsAsStrings[i]); } mSourceFiles[i] = new File(sourcePathsAsStrings[i]); } mSourcePattern = FileSystems.getDefault().getPathMatcher("glob:" + mOptions.getSourcePattern()); }