Android File Name Create makeFileName(String prefix, String filename)

Here you can find the source of makeFileName(String prefix, String filename)


Makes a 'standard' helper file name.


Apache License


Parameter Description
prefix a parameter
filename a parameter


non-null string.


public static String makeFileName(String prefix, String filename) 

Method Source Code

/*/*  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

    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/ $

import ariba.util.log.Log;
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) {
        return sb == null ? null : sb.toString();


  1. createImageName()
  2. getLocalDateTimeForFileName(Date date)
  3. getJpegFileName(long fileNumber)
  4. getMetadataFileName(long fileNumber)