Java Is File Name Valid isValidFileName(String paramString)

Here you can find the source of isValidFileName(String paramString)

Description

is Valid File Name

License

Open Source License

Declaration

public static boolean isValidFileName(String paramString) 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.IOException;

public class Main {

    public static boolean isValidFileName(String paramString) {
        boolean rtn = false;
        if (paramString != null) {
            File localFile = new File(paramString);
            try {
                if (localFile.getCanonicalPath() != null) {
                    rtn = true;//from   www  .ja v  a 2s .c  o  m
                }
            } catch (IOException ex) {
            }
        }
        return rtn;
    }

    public static String getCanonicalPath(File file) {
        String path = "";
        try {
            path = file.getCanonicalPath();
        } catch (Exception ex) {
            path = file.getAbsolutePath();
        }
        return path;
    }
}

Related

  1. isValidFileName(final String aFileName)
  2. isValidFileName(String fileName)
  3. isValidFileName(String fileName)
  4. isValidFileName(String input)
  5. isValidFilePath(String filePath)