Android File Path Get getCanonicalFile(File file)

Here you can find the source of getCanonicalFile(File file)

Description

Convert a file to canonical form.

License

Apache License

Parameter

Parameter Description
file the file to convert to canonical form

Return

current file converted to canonical format

Declaration

public static File getCanonicalFile(File file) 

Method Source Code

/*/*w ww .  j  a  v a  2s . co  m*/
    Copyright 1996-2008 Ariba, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    $Id: //ariba/platform/util/core/ariba/util/core/FileUtil.java#24 $
 */

import ariba.util.log.Log;
import java.io.File;
import java.io.IOException;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.Random;
import java.util.List;

public class Main{
    /**
        Convert a file to canonical form. On error, returns the same
        file. Java doesn't specify what might cause a failure. Most
        likely it is if you have permissions problems on the parent
        directories.

        @param file the file to convert to canonical form
        @return current file converted to canonical format
        @aribaapi documented
     */
    public static File getCanonicalFile(File file) {
        try {
            return new File(file.getCanonicalPath());
        } catch (IOException e) {
            Log.util.debug("Could not create canonical path for %s: %s",
                    file, e);
            return file;
        }
    }
}

Related

  1. getDrive(File file)
  2. getPathLastIndex(String fileName)
  3. getPathLastIndex(String fileName, int fromIndex)
  4. getRoot(File file)