Here you can find the source of quoteFileName(String filename)
Parameter | Description |
---|---|
filename | the file to quote |
public static String quoteFileName(String filename)
//package com.java2s; /******************************************************************************* * Copyright (c) 2001, 2007 Mathew A. Nelson and Robocode contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://robocode.sourceforge.net/license/cpl-v10.html * * Contributors://from w w w . ja va 2s .com * Mathew A. Nelson * - Initial API and implementation * Flemming N. Larsen * - Moved the former robocode.util.Constants and all file operations from * robocode.util.Utils into this new class * - Added/updated JavaDoc for all methods * - Added the quoteFileName(), createDir(), getRobotsDir(), getConfigDir(), * getRobocodeConfigFile(), getWindowConfigFile(), getCompilerConfigFile() *******************************************************************************/ public class Main { /** * Quotes a file name if it contains whitespaces and has not already been * quoted. * * @param filename the file to quote * @return a quoted version of the specified filename */ public static String quoteFileName(String filename) { if (filename.startsWith("\"") || filename.endsWith("\"")) { return filename; } if (System.getProperty("os.name").toLowerCase().startsWith("windows") && filename.startsWith("file://")) { filename = filename.substring(7); } if (filename.matches(".*\\s+?.*")) { return '"' + filename + '"'; } return filename; } }