Java File Name Extract extractFileNames(String[] fileNames)

Here you can find the source of extractFileNames(String[] fileNames)

Description

extract File Names

License

Open Source License

Declaration

public static String[] extractFileNames(String[] fileNames) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String[] extractFileNames(String[] fileNames) {
        String[] newFileNames = new String[fileNames.length];

        for (int i = 0; i < fileNames.length; i++) {
            newFileNames[i] = extractFileName(fileNames[i]);
        }//from www  .  ja  v a 2s.c  om

        return newFileNames;
    }

    public static String extractFileName(String fileName) {
        String newFileName = "";
        String tempStr = "";
        int counter = fileName.length() - 1;
        char ch = fileName.charAt(counter);
        while (ch != '/') {
            counter--;
            tempStr += ch;
            ch = fileName.charAt(counter);
        }

        for (int i = tempStr.length() - 1; i >= 0; i--) {
            newFileName += tempStr.charAt(i);
        }

        return newFileName;
    }
}

Related

  1. extractFileNameFromPath(final String path)
  2. extractFilenameFromPath(String path)
  3. extractFilenameFromURL(String url)
  4. extractFileNameFromUrl(String url)
  5. extractFilenameFromUrlPath(String urlPath)