Java Path Crop cropFile(File cropper, File file)

Here you can find the source of cropFile(File cropper, File file)

Description

Crop a file

License

Open Source License

Parameter

Parameter Description
cropper the cropper
file the file to be cropped

Return

the cropped file

Declaration

public static File cropFile(File cropper, File file) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**//www.j  a v a  2s . co m
     * Crop a file
     * 
     * @param cropper
     *            the cropper
     * @param file
     *            the file to be cropped
     * @return the cropped file
     */
    public static File cropFile(File cropper, File file) {
        if (file.getPath().startsWith(cropper.getPath())) {
            return new File(file.getPath().replace(cropper.getPath(), ""));
        }

        return file;
    }
}