Java File Name Create toFileName(final Object obj)

Here you can find the source of toFileName(final Object obj)

Description

to File Name

License

Apache License

Declaration

public static String toFileName(final Object obj) 

Method Source Code

//package com.java2s;
/*-// w  w w. j a  va  2  s.com
 * #%L
 * Proof Utility Library
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2014 - 2017 Live Ontologies Project
 * %%
 * 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.
 * #L%
 */

public class Main {
    public static String toFileName(final Object obj) {
        return obj.toString().replaceAll("[^a-zA-Z0-9_.-]", "_");
    }
}

Related

  1. generateFileName()
  2. generateFileName()
  3. generateFileName(String fileName)
  4. generateFileNameWithoutExtension(final String testClassName, final String testId, final boolean includeDate)
  5. getRandomFileName(@Nullable final String prefix)
  6. toFileName(String address)
  7. toFileName(String className)
  8. toFilename(String filenameOrURI)
  9. toFilename(String key, final String suffix)