Java String Shorten shortenFileName(String name)

Here you can find the source of shortenFileName(String name)

Description

shorten File Name

License

Open Source License

Declaration

public static String shortenFileName(String name) 

Method Source Code

//package com.java2s;
/*/*w w w.  j  a v a  2s.  co  m*/
 * JBoss, Home of Professional Open Source.
 *
 * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
 *
 * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
 */

public class Main {
    public static String shortenFileName(String name) {
        if (name == null)
            return name;
        String retVal;
        String tempStr = name.replace('\\', '/');
        if (tempStr.indexOf('/') >= 0) {
            retVal = tempStr.substring(tempStr.lastIndexOf('/') + 1);
        } else {
            retVal = name;
        }
        return retVal;
    }
}

Related

  1. shortenContent(String s, int maxLength)
  2. shortenCount(final long count)
  3. shortenCount(int count)
  4. shortenDbName(String dbName, int desiredLength)
  5. shortenDerivedIdentifier(final String derivdedIdentifier)
  6. shortenFileName(String text, String filename)
  7. shortenGeneratedIdentifier(final String name)
  8. shortenHash(String s)
  9. shortenLabel(String key)