Here you can find the source of concatenate(String[] args)
Parameter | Description |
---|---|
args | the arguments |
public static String concatenate(String[] args)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { /**/*from w w w . j a v a2s .c om*/ * Returns the list of arguments as space separated string for the command * line. * * @param args the arguments * * @return a comma separated string */ public static String concatenate(ArrayList<String> args) { if (args == null) { return null; } String quote = getQuoteType(); String result = ""; for (String arg : args) { if (!result.equals("")) { result += " "; } // add quotes around the arguments in order to support file names with spaces if (!arg.startsWith("-") && !arg.startsWith("\"") && !arg.startsWith("\'")) { arg = quote + arg + quote; } result += arg; } return result; } /** * Returns the list of arguments as space separated string for the command * line. Adds quotes where they seem to be needed. * * @param args the arguments * * @return a comma separated string */ public static String concatenate(String[] args) { if (args == null) { return null; } String quote = getQuoteType(); String result = ""; for (String arg : args) { if (!result.equals("")) { result += " "; } // add quotes around the arguments in order to support file names with spaces if (!arg.startsWith("-") && !arg.startsWith("\"") && !arg.startsWith("\'")) { arg = quote + arg + quote; } result += arg; } return result; } /** * Returns the quote type to use. For example around file paths with spaces. * * @return the quote type to use */ public static String getQuoteType() { String quote = ""; if (System.getProperty("os.name").lastIndexOf("Windows") != -1) { quote = "\""; } return quote; } }