Here you can find the source of escapeToFileName(String name)
Parameter | Description |
---|---|
name | any string |
public static String escapeToFileName(String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. * 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:/* ww w . java 2 s.c om*/ * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ import java.io.UnsupportedEncodingException; public class Main { /** * Create escaped filename from a string * * @param name any string * @return file compatible string */ public static String escapeToFileName(String name) { try { return java.net.URLEncoder.encode(name, "UTF-8"); } catch (UnsupportedEncodingException e) { // never expected throw new RuntimeException(e); } } }