×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
0
Language: Java
Posted by: Gerrit Viljoen
Added: Apr 30, 2014 12:40 PM
Views: 22
Convenient and safe File.getCanonicalFile().
  1.     public static File getCanonicalFile(File file) {
  2.         if (file == null) {
  3.             return null;
  4.         } else {
  5.             try {
  6.                 return file.getCanonicalFile();
  7.             } catch (IOException e) {
  8.                 return file.getAbsoluteFile();
  9.             }
  10.         }
  11.     }