Example usage for org.apache.commons.io FilenameUtils separatorsToSystem

List of usage examples for org.apache.commons.io FilenameUtils separatorsToSystem

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils separatorsToSystem.

Prototype

public static String separatorsToSystem(String path) 

Source Link

Document

Converts all separators to the system separator.

Usage

From source file:SmartlingApiExample.java

public static void main(String args[]) throws FileApiException {
    FileApiClientAdapter smartlingFAPI = new FileApiClientAdapterImpl(true, API_KEY, PROJECT_ID);

    // upload the file
    File file = new File(FilenameUtils.separatorsToSystem(PATH_TO_FILE));
    FileUploadParameterBuilder fileUploadParameterBuilder = new FileUploadParameterBuilder();
    fileUploadParameterBuilder.fileType(FILE_TYPE).fileUri(getFileUri(file)).approveContent(false)
            .callbackUrl(CALLBACK_URL);
    ApiResponse<UploadData> uploadFileResponse = smartlingFAPI.uploadFile(file, FILE_ENCODING,
            fileUploadParameterBuilder);
    System.out.println(uploadFileResponse);

    // get last modified date
    ApiResponse<FileLastModified> lastModifiedResponse = smartlingFAPI.getLastModified(getFileUri(file), null,
            LOCALE);/*from w  ww . jav a2  s  .c o m*/
    System.out.println(lastModifiedResponse);

    // rename the file
    final String fileIdentifier = "myTestFileIdentifier";
    ApiResponse<EmptyResponse> renameFileResponse = smartlingFAPI.renameFile(getFileUri(file), fileIdentifier);
    System.out.println(renameFileResponse);

    // run a search for files
    FileListSearchParams fileListSearchParams = new FileListSearchParams();
    fileListSearchParams.setUriMask(fileIdentifier);
    ApiResponse<FileList> filesListResponse = smartlingFAPI.getFilesList(fileListSearchParams);
    System.out.println(filesListResponse);

    // check the file status
    ApiResponse<FileStatus> fileStatusResponse = smartlingFAPI.getFileStatus(fileIdentifier, LOCALE);
    System.out.println(fileStatusResponse);

    // get the file back, including any translations that have been published.
    StringResponse translatedContent = smartlingFAPI.getFile(fileIdentifier, LOCALE, RetrievalType.PUBLISHED);
    System.out.println(translatedContent.getContents());

    // delete the file
    ApiResponse<EmptyResponse> deleteFileResponse = smartlingFAPI.deleteFile(fileIdentifier);
    System.out.println(deleteFileResponse);
}

From source file:net.erdfelt.android.sdkfido.util.PathUtil.java

public static String toRelativePath(File basedir, File destpath) {
    URI baseuri = basedir.toURI();
    URI otheruri = destpath.toURI();
    URI reluri = baseuri.relativize(otheruri);
    return FilenameUtils.separatorsToSystem(reluri.toASCIIString());
}

From source file:com.orient.lib.xbmc.addons.Addon.java

/**
 * Returns the path of the addon.xml file of the given addon
 * /*w  w  w  .j  av  a2 s  .  c  o m*/
 * @param id
 * @return path | null (if addon directory doesnt exist)
 */
private static String getAddonXmlPath(String id) {
    return FilenameUtils
            .separatorsToSystem(Settings.getInstance().getAddonDirPath() + "\\" + id + "\\addon.xml");
}

From source file:it.unibas.spicy.persistence.idgenerator.utils.ReadPropertiesFile.java

public void getProperties() throws FileNotFoundException, IOException {
    try (BufferedReader in = new BufferedReader(new FileReader(FilenameUtils.separatorsToSystem(path)))) {
        String line;//w w w . j  a  va 2  s  .  c  o  m
        while ((line = in.readLine()) != null) {
            String[] splitLine = line.split("=");
            switch (splitLine[0]) {
            case "commandSource":
                this.commandSource = splitLine[1];
                break;
            case "sourceInputPath":
                this.sourceInputPath = splitLine[1];
                break;
            case "commandTarget":
                this.commandTarget = splitLine[1];
                break;
            case "targetInputPath":
                this.targetInputPath = splitLine[1];
                break;
            case "targetColumns":
                this.targetColumns = splitLine[1];
                break;
            case "functionPerColumn":
                this.functionPerColumn = splitLine[1];
                break;
            case "outputFile":
                this.outputFile = splitLine[1];
                break;
            default:
                System.err.println("Wrong command!");
                System.exit(-1);
                break;
            }
        }
    } catch (IOException ex) {
        System.err.print(ex);
        System.exit(-1);
    }
}

From source file:com.smartling.api.sdk.ApiTestHelper.java

public static File getTestFile() {
    return new File(FilenameUtils.separatorsToSystem(ApiTestHelper.TEST_FILE_LOCATION));
}

From source file:it.unibas.spicy.persistence.idgenerator.utils.ExportCsv.java

public void performAction() {
    //        CSVWriter csvWriter;
    BufferedWriter bwriter;/* ww  w .j a v a 2s  . c  om*/
    try {
        bwriter = new BufferedWriter(new FileWriter(FilenameUtils.separatorsToSystem(pathToExport)));
        //            csvWriter = new CSVWriter(new FileWriter(FilenameUtils.separatorsToSystem(pathToExport)), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER);
        //            csvWriter.writeNext(header, false);
        int line = 1;
        String str = "";
        for (int i = 0; i < header.length; i++) {
            str += "\"" + header[i].trim() + "\",";
        }
        str = str.substring(0, str.length() - 1);
        str += "\n";
        for (InputDataModel output : targetValues) {
            String row = "";
            for (String s : output.getValue()) {
                if (s != null)
                    row += "\"" + s + "\",";
                else
                    row += ",";
                //                    row = row.replace("\"", "");
            }
            //                csvWriter.writeNext(row.substring(0, row.length()-1).split(","),false);
            row = row.substring(0, row.length() - 1);
            str += row + "\n";
        }
        bwriter.write(str);
        bwriter.close();
        //            csvWriter.close();
    } catch (IOException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }

}

From source file:it.unibas.spicy.persistence.idgenerator.utils.ReadCsv.java

public ArrayList<InputDataModel> readInputCsv(ArrayList<ColumnMatcherModel> cmmList) {
    ArrayList<InputDataModel> inputData = new ArrayList<>();
    try {/*from  w  w  w.  j  av  a 2s  .c o  m*/
        String[] nextLine;
        //            CSVReader reader = new CSVReader(new FileReader(FilenameUtils.separatorsToSystem(this.path)));
        Reader r = new FileReader(FilenameUtils.separatorsToSystem(this.path));
        CSVReader reader = new CSVReaderBuilder(r).withFieldAsNull(CSVReaderNullFieldIndicator.EMPTY_SEPARATORS)
                .build();

        nextLine = reader.readNext();
        ArrayList<Integer> colNums = new ArrayList<>();
        ArrayList<String> colName = new ArrayList<>();
        for (ColumnMatcherModel cmm : cmmList) {
            for (int i = 0; i < nextLine.length; i++) {
                if (nextLine[i].equals(cmm.getSourceColumn())) {
                    colNums.add(i);
                    colName.add(cmm.getSourceColumn());
                    break;
                }
            }
        }

        while ((nextLine = reader.readNext()) != null) {
            InputDataModel idm = new InputDataModel();
            for (int i = 0; i < colNums.size(); i++) {
                //avenet 20170721
                String value;
                if (nextLine[colNums.get(i)] != null)
                    value = nextLine[colNums.get(i)].trim();
                else
                    value = null;
                idm.addValue(value);
                idm.addKey(colName.get(i));
            }
            inputData.add(idm);
        }

    } catch (Exception e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }
    return inputData;
}

From source file:com.googlecode.fascinator.common.FascinatorHome.java

/**
 * Gets the Fascinator home directory, which is used for configuration,
 * storage, etc. The directory can be set through the following:
 * //from ww w .ja  va  2s.  c  o m
 * <ul>
 * <li>Environment variable: FASCINATOR_HOME</li>
 * <li>System property: fascinator.home</li>
 * </ul>
 * 
 * @return a directory path
 */
public static String getPath() {
    String home = System.getProperty(SYSTEM_KEY, getenv("FASCINATOR_HOME", DEFAULT_PATH));
    return FilenameUtils.separatorsToSystem(home);
}

From source file:net.erdfelt.android.sdkfido.project.Dir.java

public File getFile(String path) {
    return new File(this.basedir, FilenameUtils.separatorsToSystem(path));
}

From source file:net.erdfelt.android.sdkfido.tasks.ProjectCopySourceTask.java

@Override
public void run(TaskQueue tasks) throws Throwable {
    for (BaseDir basedir : repo.getBasedirs()) {
        String include = basedir.getPath();
        File sourceDir = new File(git.getDir(), FilenameUtils.separatorsToSystem(include));
        project.startSubProject(basedir.getProject());
        project.copySource(sourceDir);//  w  ww .  java2  s  .co m
    }
}