Java File Base Name Get basename(String name, String split)

Here you can find the source of basename(String name, String split)

Description

return String basename

License

Open Source License

Parameter

Parameter Description
name String
split String

Return

String com.ztesoft.ispp.ne --> ne

Declaration

public static String basename(String name, String split) 

Method Source Code

//package com.java2s;
/**//from  w w  w .ja va2  s .  c om
  * Copyright 2010 ZTEsoft Inc. All Rights Reserved.
  *
  * This software is the proprietary information of ZTEsoft Inc.
  * Use is subject to license terms.
  * 
  * $Tracker List
  * 
  * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create 
  * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 
  *  
  *  
  */

public class Main {
    /**
      * return String basename
      * 
      * @param name
      *            String
      * @param split
      *            String
      * @return String com.ztesoft.ispp.ne --> ne
      */
    public static String basename(String name, String split) {
        if (name == null || name.equals("")) {
            return "";
        }
        if (split == null || split.equals("")) {
            split = ".";
        }

        int index = name.lastIndexOf(split);
        if (index >= 0) {
            return name.substring(index + split.length());
        }

        return name;
    }
}

Related

  1. baseName(String filename)
  2. baseName(String filename)
  3. basename(String filename)
  4. baseName(String fn)
  5. baseName(String name)
  6. basename(String path)
  7. basename(String path)
  8. basename(String path)
  9. baseName(String path)