Java Is Link File isLink(java.io.File f)

Here you can find the source of isLink(java.io.File f)

Description

is Link

License

Open Source License

Declaration

public static boolean isLink(java.io.File f) 

Method Source Code

//package com.java2s;
/******************************************************************************
 *
 * Copyright (c) 2005-2011 Cryptzone Group AB. All Rights Reserved.
 * /*from  w  w w .  java 2 s . c o  m*/
 * This file contains Original Code and/or Modifications of Original Code as
 * defined in and that are subject to the MindTerm Public Source License,
 * Version 2.0, (the 'License'). You may not use this file except in compliance
 * with the License.
 * 
 * You should have received a copy of the MindTerm Public Source License
 * along with this software; see the file LICENSE.  If not, write to
 * Cryptzone Group AB, Drakegatan 7, SE-41250 Goteborg, SWEDEN
 *
 *****************************************************************************/

public class Main {
    public static boolean isLink(java.io.File f) {
        // if last part of absolute and canonical path differ, this is a link
        try {
            String ap[] = f.getAbsolutePath().split(java.io.File.pathSeparator);
            String cp[] = f.getCanonicalPath().split(java.io.File.pathSeparator);
            return !ap[ap.length - 1].equals(cp[cp.length - 1]);
        } catch (Throwable t) {
        }
        return false;
    }
}

Related

  1. isLink(@Nonnull File file)
  2. isLink(File file)
  3. isLink(File file)
  4. isLink(File file)
  5. isLink(final File file)