Example usage for org.apache.commons.exec.util StringUtils fixFileSeparatorChar

List of usage examples for org.apache.commons.exec.util StringUtils fixFileSeparatorChar

Introduction

In this page you can find the example usage for org.apache.commons.exec.util StringUtils fixFileSeparatorChar.

Prototype

public static String fixFileSeparatorChar(final String arg) 

Source Link

Document

Fixes the file separator char for the target platform using the following replacement.

Usage

From source file:npanday.executable.ArgUtils.java

/**
 * Takes care of quoting individually per part. For example,
 * if you pass <code>"/go:", new File("c:\\with space")</code>, it will yield
 * <code>/go:"c:\with space"</code>
 *//* w  w w  .  j  av a  2 s.co m*/
public static String combine(Object... objects) {
    StringBuilder command = new StringBuilder();
    for (Object item : objects) {
        if (item == null) {
            continue;
        }

        if (item instanceof File) {
            command.append(StringUtils
                    .quoteArgument(StringUtils.fixFileSeparatorChar(((File) item).getAbsolutePath())));
        } else if (item instanceof String) {
            command.append(StringUtils.quoteArgument((String) item));
        } else {
            command.append(StringUtils.quoteArgument(item.toString()));
        }
    }

    return command.toString();
}