Here you can find the source of toFile(String inFile)
public static File toFile(String inFile)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static File toFile(String inFile) { return toFile(inFile, true, true); }/*from w w w . j av a 2 s .c o m*/ public static File toFile(String inFile, boolean inReturnFile, boolean inReturnDir) { if (isBlank(inFile)) { return null; } final File f = new File(inFile); if (inReturnFile == false && isFile(f)) { return null; } if (inReturnDir == false && isDir(f)) { return null; } return f; } public static boolean isBlank(String inValue) { return inValue == null || inValue.trim().isEmpty(); } public static boolean isFile(File inFile) { return inFile != null && inFile.isFile(); } public static boolean isFile(String inFilePath) { return isNotBlank(inFilePath) && isFile(new File(inFilePath)); } /** * Same as isDirectory() * @param inDir * @return */ public static boolean isDir(File inDir) { return inDir != null && inDir.isDirectory(); } public static boolean isDir(String inDirPath) { return isNotBlank(inDirPath) && isDir(new File(inDirPath)); } public static boolean isNotBlank(String inValue) { return !isBlank(inValue); } public static boolean isDirectory(File inDir) { return isDir(inDir); } public static boolean isDirectory(String inDir) { return isDir(inDir); } }