Here you can find the source of quoteWhitespaces(String path)
static public String quoteWhitespaces(String path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Liviu Ionescu.//from w w w .j a va 2s. co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Liviu Ionescu - initial version *******************************************************************************/ public class Main { static public String quoteWhitespaces(String path) { path = path.trim(); // Escape the spaces in the path/filename if it has any String[] segments = path.split("\\s"); //$NON-NLS-1$ if (segments.length > 1) { if (path.startsWith("\"") || path.startsWith("'")) return path; return "\"" + path + "\""; } else { return path; } } }