Java Code Examples for org.apache.commons.io.FilenameUtils#separatorsToSystem()

The following examples show how to use org.apache.commons.io.FilenameUtils#separatorsToSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteSourceInputStreamTest.java    From commons-imaging with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadFromStream() throws IOException, ImageReadException {

    final String imagePath = FilenameUtils.separatorsToSystem(ICO_IMAGE_FILE);
    final File imageFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, imagePath);
    try(BufferedInputStream imageStream = new BufferedInputStream(new FileInputStream(imageFile))) {
     // ByteSourceInputStream is created inside of following method
        BufferedImage bufferedImage = Imaging.getBufferedImage(imageStream,
                Collections.singletonMap(ImagingConstants.PARAM_KEY_FILENAME, ICO_IMAGE_FILE));

        assertEquals(bufferedImage.getWidth(), ICO_IMAGE_WIDTH);
        assertEquals(bufferedImage.getHeight(), ICO_IMAGE_HEIGHT);
    }
}
 
Example 2
Source File: ImagingGuessFormatTest.java    From commons-imaging with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource("data")
public void testGuessFormat(ImageFormats expectedFormat, String pathToFile) throws Exception {
    final String imagePath = FilenameUtils.separatorsToSystem(pathToFile);
    final File imageFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, imagePath);

    final ImageFormat guessedFormat = Imaging.guessFormat(imageFile);
    assertEquals(expectedFormat, guessedFormat);
}
 
Example 3
Source File: MyPrinterUtils.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 只能打印 pdf 文件 </br>
 * windows 中,发送 pdf 格式文件,到指定打印机打印(仅能打印 pdf 格式文件)。因为是调用 windows
 * 命令,故文件路径分隔符要完全满足 windows 要求,否则找不到文件</br>
 * <p/>
 * 本方法应用开源软件 Ghostscript 和 GSView 打印 pdf 文件,使用之前,首先安装 Ghostscript 和
 * GSView。他们可以下述地址下载得到:</br>
 * <p/>
 * Ghostscript #http://www.ghostscript.com/ . 它是一个 windows 下面的安装文件,文件名是 gs871w32.exe</br>
 * <p/>
 * GSView # http://pages.cs.wisc.edu/~ghost/gsview/index.htm.  安装文件名 gsv49w32.exe </br>
 * <p/>
 * gsprint 命令的其他参数见 http://pages.cs.wisc.edu/~ghost/gsview/index.htm</br>
 * <p/>
 * 具体的打印设置,需要设置打印机驱动本身的设置。
 *
 * @param gspprintPath gsprint 命令所在目录,写法如 e:\\Program
 *                     Files\\Ghostgum\\gsview\\gsprint.exe 注意路径是双斜线,可以不带 exe 后缀名
 * @param printerName  windows 中的打印机名称,即 windows 打印机控制面板中看到的打印机名字,如 Adobe PDF
 * @param pdfFilePath  打印的 pdf 文件路径,如 d:\\sample.pdf 注意路径是双斜线
 */
public static void printPDFFile(String gspprintPath, String printerName,
                                String pdfFilePath) {
    try {

        // cmd.exe /c call 和 cmd.exe /c start 命令区别
        // start命令路径参数中不支持空格,call通过引号括起来,路径参数可以支持空格。
        // gspprintPath: e:\\Program
        // Files\\Ghostgum\\gsview\\gsprint.exe(exe 可以不写)
        // printerName: Adobe PDF
        // pdfFilePath: d:\sample.pdf

        if (!new File(gspprintPath).exists()) {
            log.info("file does not exsit: " + gspprintPath);
            return;
        }
        if (!new File(pdfFilePath).exists()) {
            log.info("file does not exsit: " + pdfFilePath);
            return;
        }
        //所有的命令字符串,都用 引号括起来
        String cmd = "cmd.exe /c call \""
                + FilenameUtils.separatorsToSystem(gspprintPath)
                + "\" -printer " + "\"" + printerName + "\" "
                + FilenameUtils.separatorsToSystem(pdfFilePath);
        log.info("print cmd is: " + cmd);
        // cmd.exe /c call "e:\Program
        // Files\Ghostgum\gsview\gsprint" -printer "Adobe PDF" d:/1.pdf

        Runtime.getRuntime().exec(cmd);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: S3DataManagerTest.java    From aws-codebuild-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testTrimPrefixBaseWithTrailingSlash() {
    String prefixWithSlash = FilenameUtils.separatorsToSystem("/tmp/dir/");  // "/tmp/dir/" in Linux, "\tmp\dir\" in Windows.
    String path = FilenameUtils.separatorsToSystem("/tmp/dir/folder/file.txt");

    assertEquals(FilenameUtils.separatorsToSystem("folder/file.txt"), ZipSourceCallable.trimPrefix(path, prefixWithSlash));
}
 
Example 5
Source File: S3DataManagerTest.java    From aws-codebuild-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetRelativePathStringBaseDirWithoutTrailingSlash() {
    String prefixNoSlash = FilenameUtils.separatorsToSystem("/tmp/dir"); // "/tmp/dir" in Linux, "\tmp\dir" in Windows.
    String path = FilenameUtils.separatorsToSystem("/tmp/dir/folder/file.txt");

    assertEquals(FilenameUtils.separatorsToSystem("folder/file.txt"), ZipSourceCallable.trimPrefix(path, prefixNoSlash));
}
 
Example 6
Source File: SystemTest.java    From app-runner with MIT License 5 votes vote down vote up
private static void updateHeaderAndCommit(AppRepo mavenApp, String replacement) throws IOException, GitAPIException {
    File indexHtml = new File(mavenApp.originDir, FilenameUtils.separatorsToSystem("src/main/resources/web/index.html"));
    String newVersion = FileUtils.readFileToString(indexHtml, "UTF-8").replaceAll("<h1>.*</h1>", "<h1>" + replacement + "</h1>");
    FileUtils.write(indexHtml, newVersion, "UTF-8", false);
    mavenApp.origin.add().addFilepattern(".").call();
    mavenApp.origin.commit().setMessage("Updated index.html").setAuthor("Dan F", "[email protected]").call();
}
 
Example 7
Source File: FilenameTestsUtils.java    From pipeline-utility-steps-plugin with MIT License 5 votes vote down vote up
/**
 * Converts all separators to the system separator
 * and escape them for Windows.
 *
 * @param path  the path to be changed, null ignored
 * @return the updated path
 */
public static String separatorsToSystemEscaped(String path) {
    if (path == null) {
        return null;
    }
    String pathConverted=FilenameUtils.separatorsToSystem(path);
    return pathConverted.replace("\\", "\\\\");
}
 
Example 8
Source File: FileFixture.java    From hsac-fitnesse-fixtures with Apache License 2.0 4 votes vote down vote up
private String cleanupPath(String fullPath) {
    return FilenameUtils.separatorsToSystem(fullPath);
}
 
Example 9
Source File: PngMultipleRoundtripTest.java    From commons-imaging with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws Exception {
    final String imagesFolderPath = FilenameUtils.separatorsToSystem(
            "src\\test\\data\\images\\png\\3");
    final File imagesFolder = new File(imagesFolderPath);
    assertTrue(imagesFolder.exists() && imagesFolder.isDirectory());

    final File files[] = imagesFolder.listFiles();
    for (final File file : files) {
        final File imageFile = file;
        if (!imageFile.isFile()) {
            continue;
        }
        if (!imageFile.getName().toLowerCase().endsWith(".png")) {
            continue;
        }

        Debug.debug();
        Debug.debug("imageFile", imageFile);

        File lastFile = imageFile;
        for (int j = 0; j < 10; j++) {
            final Map<String, Object> readParams = new HashMap<>();
            // readParams.put(ImagingConstants.BUFFERED_IMAGE_FACTORY,
            // new RgbBufferedImageFactory());
            final BufferedImage image = Imaging.getBufferedImage(lastFile,
                    readParams);
            assertNotNull(image);

            final File tempFile = File.createTempFile(imageFile.getName() + "." + j
                    + ".", ".png");
            Debug.debug("tempFile", tempFile);

            final Map<String, Object> writeParams = new HashMap<>();
            Imaging.writeImage(image, tempFile,
                    ImageFormats.PNG, writeParams);

            lastFile = tempFile;
        }
    }
}
 
Example 10
Source File: PicasaFaces.java    From PicasaDBReader with MIT License 4 votes vote down vote up
public void processImages(String regex, String replacement, String output, boolean prefix, String convert) throws IOException, InterruptedException{
	StringBuilder csv = new StringBuilder("person;prefix;filename;original image path;transformed image path;image width;image height;face x;face y;face width;face height\n");
	for(String person:personFaces.keySet()){
		File folderPerson = new File(output+person);
		if(convert!=null && !folderPerson.exists()){
			folderPerson.mkdir();
		}
		
		int i=0;
		for(Face f:personFaces.get(person)){
			String path;
			path=FilenameUtils.separatorsToSystem(f.img.path);
			if(regex!=null && replacement!=null){
				path = path.replaceAll(regex, replacement);
			}
			int x=f.x;
			int y=f.y;
			String separator = File.separator;
			if(separator.equals("\\")){
				separator="\\\\";
			}
			String [] file = path.split(separator);
			String prefixStr = "";
			if(prefix){
				prefixStr = ""+ i +"_";
			}
			String filename = output + person + File.separator + prefixStr+file[file.length-1];
			if(convert!=null && new File(filename).exists()){
				System.out.println("Warning, the filename already exist: "+person + File.separator + prefixStr+file[file.length-1]);
			}
			csv.append(person);
			csv.append(";");
			if(prefix){
				csv.append(i);
			}else{
				csv.append("none");
			}
			csv.append(";");
			csv.append(file[file.length-1]);
			csv.append(";");
			csv.append(f.img.path);
			csv.append(";");
			csv.append(path);
			csv.append(";");
			csv.append(f.img.w);
			csv.append(";");
			csv.append(f.img.h);
			csv.append(";");
			csv.append(f.x);
			csv.append(";");
			csv.append(f.y);
			csv.append(";");
			csv.append(f.w);
			csv.append(";");
			csv.append(f.h);
			csv.append("\n");
			
			if(convert!=null){
				
				if(File.separator.equals("\\")){
					path = "\""+path+"\"";
					filename = "\""+filename+"\"";
				}
				String []cmd = {convert,path, "-crop", f.w+"x"+f.h+"+"+x+"+"+y, filename};
				Process p = Runtime.getRuntime().exec(cmd);
				p.waitFor();
			}
			i++;
		}
	}
	FileWriter fw = new FileWriter(output+"faces.csv");
       BufferedWriter bw = new BufferedWriter(fw);
       bw.write(csv.toString());
       bw.close();
}
 
Example 11
Source File: PlotTab.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
private void jButtonAceptGnuPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptGnuPActionPerformed

        if (!this.jTextFieldResultPath.getText().equals("")) {
            String outPath = getDirectory("open", JFileChooser.DIRECTORIES_ONLY);
            if(!outPath.equals("")){
                
            File resultFile = new File(this.jTextFieldResultPath.getText());
            String resultDirectory = resultFile.getAbsolutePath();
            String gnuPlotPath = this.jTextFieldGNUPath.getText();
            String gnuplotScriptPath = null;
            File gnuplotDir = new File(gnuPlotPath);
            if (!gnuplotDir.exists()) {
                JOptionPane.showMessageDialog(this, "Gnuplot directory not found: " + gnuPlotPath, "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            String algShortName[] = new String[this.jTableAlgoritms.getRowCount()];
            String algName[] = new String[this.jTableAlgoritms.getRowCount()];
            for (int i = 0; i < this.jTableStreams.getRowCount(); i++) {
                String streamName = this.jTableStreams.getModel().getValueAt(i, 0).toString();
                String streamShortName = this.jTableStreams.getModel().getValueAt(i, 1).toString();
                for (int j = 0; j < this.jTableAlgoritms.getRowCount(); j++) {
                    algName[j] = this.jTableAlgoritms.getModel().getValueAt(j, 0).toString();
                    algShortName[j] = this.jTableAlgoritms.getModel().getValueAt(j, 1).toString();
                    File inputFile = new File(FilenameUtils.separatorsToSystem(
                            this.path + "\\" + streamName + "\\" + algName[j]));

                    if (!inputFile.exists()) {
                        JOptionPane.showMessageDialog(this, "File not found: "
                                + inputFile.getAbsolutePath(),
                                "Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                }

                gnuplotScriptPath = resultDirectory + File.separator
                        + resultFile.getName() + ".plt";
                String script = createScript(streamName, algName, algShortName, outPath);
                File scriptFile = writeScriptToFile(gnuplotScriptPath, script);
                String gnuplotCommand = gnuPlotPath + File.separator + "gnuplot \""
                        + gnuplotScriptPath + "\"";
                String line, gnuplotOutput = "";
                try {
                    Process p = Runtime.getRuntime().exec(gnuplotCommand);

                    BufferedReader err = new BufferedReader(new InputStreamReader(p
                            .getErrorStream()));
                    while ((line = err.readLine()) != null) {
                        gnuplotOutput += line + System.getProperty("line.separator");
                    }
                    err.close();
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(this, "Error while executing gnuplot script",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    throw new RuntimeException("Error while executing gnuplot script:"
                            + scriptFile, ex);

                }
                if (this.jCheckBoxDeleteScript.isSelected()) {
                    scriptFile.delete();
                }
            }

            //Completed
            JOptionPane.showMessageDialog(this, "Figures created at " + (new File(resultFile.getAbsolutePath())).getParent(),
                    "", JOptionPane.INFORMATION_MESSAGE);
        }
        } else {
            JOptionPane.showMessageDialog(this, "Plot output file option not set!",
                    "Error", JOptionPane.ERROR_MESSAGE);
        }

    }
 
Example 12
Source File: SummaryTab.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
public void summaryCMD(String[] measures, String[] types){
     List<Measure> algmeasures = new ArrayList<>();
    List<Stream> streams = new ArrayList<>();
    List<String> algPath = new ArrayList<>();
    List<String> algShortNames = new ArrayList<>();
   
 
    boolean type = true;
    for (int k = 0; k < measures.length; k++) {
        type = types[k].equals("Mean");
        Measure m = new Measure(measures[k],measures[k], type,0);
        algmeasures.add(m);

    }
    String path = this.jTextFieldResultsPath.getText();
    for (int i = 0; i < streamModel.getRowCount(); i++) {
       
        algPath.clear();
        for (int j = 0; j < algoritmModel.getRowCount(); j++) {
            File inputFile = new File(FilenameUtils.separatorsToSystem(
                    path + "\\" + streamModel.getValueAt(i, 0) + "\\" + algoritmModel.getValueAt(j, 0)));
            File streamFile = new File(FilenameUtils.separatorsToSystem(
                    path + "\\" + streamModel.getValueAt(i, 0)));
            if (!inputFile.exists()) {
                System.out.println("File not found: "+ inputFile.getAbsolutePath());
                        
                return;
            } else {
                String algorithmPath = FilenameUtils.separatorsToSystem(
                        path + "\\" + streamModel.getValueAt(i, 0).toString() + "\\"
                        + algoritmModel.getValueAt(j, 0).toString());
                algPath.add(algorithmPath);
                if (i == 0) {
                    algShortNames.add(algoritmModel.getValueAt(j, 1).toString());
                }
               
            }
        }
        Stream s = new Stream(streamModel.getValueAt(i, 1).toString(), algPath, algShortNames, algmeasures);
        streams.add(s);
    }

    //create summary
    try {
        summary = new Summary(streams, FilenameUtils.separatorsToSystem(path + File.separator));
        jButtonSummarize.setEnabled(true);
        String summaryPath = this.jTextFieldResultsPath.getText()+File.separator;
        
                summary.invertedSumariesPerMeasure(summaryPath);
                summary.computeWinsTiesLossesHTML(summaryPath);
                summary.computeWinsTiesLossesLatex(summaryPath);
                summary.generateHTML(summaryPath);
                summary.generateLatex(summaryPath);
               System.out.println("Summaries created at: " + summaryPath);

    } catch (Exception exc) {
       //  System.err.println("Problems generating summaries");
                

    }

}
 
Example 13
Source File: SummaryTab.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
private void jButtonShowSummaryActionPerformed(java.awt.event.ActionEvent evt) {

        if (this.jTextFieldResultsPath.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "Directory not found",
                    "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        List<Measure> algmeasures = new ArrayList<>();
        List<Stream> streams = new ArrayList<>();
        List<String> algPath = new ArrayList<>();
        List<String> algShortNames = new ArrayList<>();
        int count = 0;
        for (int i = 0; i < this.measureModel.getRowCount(); i++) {
            for (int j = 0; j < this.jComboBoxMeasure.getItemCount(); j++) {
                if (this.measureModel.getValueAt(i, 0).equals(this.jComboBoxMeasure.getItemAt(j))) {
                    count++;
                }
                if (this.measureModel.getValueAt(i, 0).equals("") || this.measureModel.getValueAt(i, 1).equals("")
                        || this.measureModel.getValueAt(i, 2) == null) {
                    JOptionPane.showMessageDialog(this, "There are fields incompleted in Table",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

            }
        }
        boolean type = true;
        for (int k = 0; k < this.measureModel.getRowCount(); k++) {
            type = this.measureModel.getValueAt(k, 2).equals("Mean");
            Measure m = new Measure(this.measureModel.getValueAt(k, 1).toString(),this.measureModel.getValueAt(k, 0).toString(), type,0);
            algmeasures.add(m);

        }
        String path = this.jTextFieldResultsPath.getText();
        for (int i = 0; i < streamModel.getRowCount(); i++) {
           
            algPath.clear();
            for (int j = 0; j < algoritmModel.getRowCount(); j++) {
                File inputFile = new File(FilenameUtils.separatorsToSystem(
                        path + "\\" + streamModel.getValueAt(i, 0) + "\\" + algoritmModel.getValueAt(j, 0)));
                File streamFile = new File(FilenameUtils.separatorsToSystem(
                        path + "\\" + streamModel.getValueAt(i, 0)));
                if (!inputFile.exists()) {
                    JOptionPane.showMessageDialog(this, "File not found: "
                            + inputFile.getAbsolutePath(),
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else {
                    String algorithmPath = FilenameUtils.separatorsToSystem(
                            path + "\\" + streamModel.getValueAt(i, 0).toString() + "\\"
                            + algoritmModel.getValueAt(j, 0).toString());
                    algPath.add(algorithmPath);
                    if (i == 0) {
                        algShortNames.add(algoritmModel.getValueAt(j, 1).toString());
                    }
                   
                }
            }
            Stream s = new Stream(streamModel.getValueAt(i, 1).toString(), algPath, algShortNames, algmeasures);
            streams.add(s);
        }

        //create summary
        try {
            summary = new Summary(streams, FilenameUtils.separatorsToSystem(path + "\\"));
            jButtonSummarize.setEnabled(true);
            SummaryTable[] table = summary.showSummary();
            SummaryViewer summaryViewer = new SummaryViewer(table, summary,jTextFieldResultsPath.getText());

        } catch (Exception exc) {
            JOptionPane.showMessageDialog(this, "Problems generating summaries",
                    "Error", JOptionPane.ERROR_MESSAGE);

        }

    }
 
Example 14
Source File: AnalyzeTab.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
private void jButtonTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTestActionPerformed
    if (this.jTextFieldResultsPath.getText().equals("")) {
        JOptionPane.showMessageDialog(this, "Directory not found",
                "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
     List<Measure> algmeasures = new ArrayList<>();
    List<Stream> streams = new ArrayList<>();
    List<String> algPath = new ArrayList<>();
    List<String> algShortNames = new ArrayList<>();
    int count = 0;
    boolean type = true;
    type = this.jComboBoxType.getSelectedItem().toString().equals("Mean");
    Measure m = new Measure(this.jComboBoxMeasure.getSelectedItem().toString(),
            this.jComboBoxMeasure.getSelectedItem().toString(),type, 0);
    algmeasures.add(m);
    String path = this.jTextFieldResultsPath.getText();
    for (int i = 0; i < streamModel.getRowCount(); i++) {
       
        algPath.clear();
        for (int j = 0; j < algoritmModel.getRowCount(); j++) {
            File inputFile = new File(FilenameUtils.separatorsToSystem(
                    path + "\\" + streamModel.getValueAt(i, 0) + "\\" + algoritmModel.getValueAt(j, 0)));
            File streamFile = new File(FilenameUtils.separatorsToSystem(
                    path + "\\" + streamModel.getValueAt(i, 0)));
            if (!inputFile.exists()) {
                JOptionPane.showMessageDialog(this, "File not found: "
                        + inputFile.getAbsolutePath(),
                        "Error", JOptionPane.ERROR_MESSAGE);
                return;
            } else {
                String algorithmPath = FilenameUtils.separatorsToSystem(
                        path + "\\" + streamModel.getValueAt(i, 0).toString() + "\\"
                        + algoritmModel.getValueAt(j, 0).toString());
                algPath.add(algorithmPath);
                if (i == 0) {
                    algShortNames.add(algoritmModel.getValueAt(j, 1).toString());
                }
               
            }
        }
        Stream s = new Stream(streamModel.getValueAt(i, 1).toString(), algPath, algShortNames, algmeasures);
        streams.add(s);
    }

    //Statistical Test 
    StatisticalTest test = new StatisticalTest(streams);
    try {
        // test.readCSV(this.jTextFieldCSV.getText());
        test.readData();
    } catch (Exception exp) {
        JOptionPane.showMessageDialog(this, "Problem with csv file",
                "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }

    test.avgPerformance();
    this.jTextAreaOut.append("P-values involving all algorithms\n");
    this.jTextAreaOut.append(System.getProperty("line.separator"));
    this.jTextAreaOut.append("P-value computed by Friedman Test: " + test.getFriedmanPValue() + "\n");
    this.jTextAreaOut.append("P-value computed by Iman and Daveport Test: " + test.getImanPValue() + "\n");

    rank = test.getRankAlg();
    this.jTextAreaOut.append(System.getProperty("line.separator"));
    this.jTextAreaOut.append("Ranking of the algorithms\n");
    this.jTextAreaOut.append(System.getProperty("line.separator"));
    rank.stream().forEach((RankPerAlgorithm rank1) -> {
        this.jTextAreaOut.append(rank1.algName + ": " + rank1.rank + "\n");
    });

    switch (jComboBoxTest.getSelectedItem().toString()) {
        case "Holm":
            pvalues = test.holmTest();
            break;
        case "Shaffer":
            pvalues = test.shafferTest();
            break;
        case "Nemenyi":
            pvalues = test.nemenyiTest();
    }
    this.jTextAreaOut.append(System.getProperty("line.separator"));
    this.jTextAreaOut.append("P-values of classifiers against each other\n");
    this.jTextAreaOut.append(System.getProperty("line.separator"));
    pvalues.stream().forEach((pvalue) -> {
        this.jTextAreaOut.append(pvalue.algName1 + " vs " + pvalue.algName2 + ": " + pvalue.PValue + "\n");
    });
    jButtonImage.setEnabled(true);
    //
}
 
Example 15
Source File: ExperimeterCLI.java    From moa with GNU General Public License v3.0 4 votes vote down vote up
public void setStreams(String[] streams) {
    for(int i = 0; i < streams.length; i++){
        streams[i] =  FilenameUtils.separatorsToSystem(streams[i]);
    }
    this.streams = streams;
}
 
Example 16
Source File: WebUi.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
private static File posixPathToFile(String path, String... otherParts) {
  return new File(FilenameUtils.separatorsToSystem(posixPath(path, otherParts)));
}
 
Example 17
Source File: Photocopier.java    From multi-module-maven-release-plugin with MIT License 4 votes vote down vote up
public static File folderForSampleProject(String moduleName) {
    return new File(FilenameUtils.separatorsToSystem("target/samples/" + moduleName + "/" + UUID.randomUUID()));
}
 
Example 18
Source File: ResourceUtils.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 
 *  ResourceUtils.iterateRelativeParents("c:/temp/hello/SRC/hello.mod ", true) :
 *  yields :
 *  
 *  SRC
 *	hello\SRC
 *	temp\hello\SRC
 *
*  ResourceUtils.iterateRelativeParents("c:/temp/hello/SRC/hello.mod ", false) :
 * yields :
 * 
 * temp\
 * temp\hello\
 * temp\hello\SRC\
 *  
 * @return
 */
public static Iterator<String> iterateRelativeParents(String absolutePath, boolean isReverse) {
	final String path = FilenameUtils.separatorsToSystem(absolutePath);
	
	if (isReverse) {
		return new Iterator<String>() {
			
			int lastSlashIdx = path.lastIndexOf(File.separatorChar, path.length());
			int idx = lastSlashIdx;
			
			@Override
			public void remove() {
				throw new NotImplementedException();
			}
			
			@Override
			public String next() {
				return path.substring(idx + 1, lastSlashIdx);
			}
			
			@Override
			public boolean hasNext() {
				idx = path.lastIndexOf(File.separatorChar, idx - 1);
				return idx > -1;
			}
		};
	}
	else{
		return new Iterator<String>() {
			int lastSlashIdx = path.indexOf(File.separatorChar, 0);
			int idx = lastSlashIdx;
			
			@Override
			public void remove() {
				throw new NotImplementedException();
			}
			
			@Override
			public String next() {
				return path.substring(lastSlashIdx + 1, idx + 1);
			}
			
			@Override
			public boolean hasNext() {
				idx = path.indexOf(File.separatorChar, idx + 1);
				return idx > -1;
			}
		};
	}
}
 
Example 19
Source File: SetupServiceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void makeWorkingDir(File repoFolder) throws IOException {
	repoFolder.mkdirs();
	repoFolder.mkdir();

	File dbDir = new File(repoFolder, "db");
	FileUtils.forceMkdir(dbDir);

	// build phisically the working directory
	// and change settings config
	String docDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/docs/");
	FileUtils.forceMkdir(new File(docDir));
	String indexDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/index/");
	FileUtils.forceMkdir(new File(indexDir));
	String userDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/users/");
	FileUtils.forceMkdir(new File(userDir));
	String pluginDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/plugins/");
	FileUtils.forceMkdir(new File(pluginDir));
	String importDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/impex/in/");
	FileUtils.forceMkdir(new File(importDir));
	String exportDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/impex/out/");
	FileUtils.forceMkdir(new File(exportDir));
	String logDir = FilenameUtils.separatorsToUnix(repoFolder.getPath() + "/logs/");
	FileUtils.forceMkdir(new File(logDir));
	String dbDirectory = FilenameUtils.separatorsToSystem(repoFolder.getPath() + "/db/");

	ContextProperties pbean = Context.get().getProperties();
	pbean.setProperty("store.1.dir", docDir);
	pbean.setProperty("store.write", "1");
	pbean.setProperty("index.dir", indexDir);
	pbean.setProperty("conf.userdir", userDir);
	pbean.setProperty("conf.plugindir", pluginDir);
	pbean.setProperty("conf.importdir", importDir);
	pbean.setProperty("conf.exportdir", exportDir);
	pbean.setProperty("conf.logdir", logDir);
	pbean.setProperty("conf.dbdir", dbDirectory);
	pbean.write();

	// Refresh the current logging location
	try {
		String log4jPath = URLDecoder.decode(this.getClass().getResource("/log.xml").getPath(), "UTF-8");
		System.err.println("log4jPath = " + log4jPath);
		Log4jConfigurer.initLogging(log4jPath);
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}

	reloadContext();
}
 
Example 20
Source File: MyFilenameUtils.java    From spring-boot with Apache License 2.0 2 votes vote down vote up
/**
 * 根据操作系统类型(windows,linux),自动替换文件路径中的分隔符为操作系统类型,windows 为 \ , linux 为 /
 *
 * @param path
 * @return
 */
public static String formateSeparatorsToSystem(String path) {
    return FilenameUtils.separatorsToSystem(path);
}