Here you can find the source of makeFileName(String prefix, String filename)
Parameter | Description |
---|---|
prefix | a parameter |
filename | a parameter |
public static String makeFileName(String prefix, String filename)
/*/* w w w.ja v a2 s . c o m*/ Copyright 1996-2008 Ariba, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. $Id: //ariba/platform/util/core/ariba/util/core/FileUtil.java#24 $ */ import ariba.util.log.Log; import java.io.File; import java.io.IOException; import java.io.FileFilter; import java.io.FilenameFilter; import java.util.Random; import java.util.List; public class Main{ /** * Makes a 'standard' helper file name. by prepending the prefix, and then stripping off the * directory name of the filename (if any). * * @param prefix * @param filename * @return non-null string. */ public static String makeFileName(String prefix, String filename) { FastStringBuffer sb = null; if (filename != null) { String[] parts = filename.split("[/|\\\\]"); sb = new FastStringBuffer(prefix); for (int i = 0; i < parts.length; i++) { // skip over the first part of the path if there is more than 1 part if ((i == 0 && parts.length == 1) || i > 0) { sb.append(parts[i]); } } } return sb == null ? null : sb.toString(); } }