Here you can find the source of getCanonicalFile(final File file)
Parameter | Description |
---|---|
file | File to return the canonical file for or <code>null</code>. |
null
if the input was null
.
public static File getCanonicalFile(final File file)
//package com.java2s; /**//from w w w. j av a 2 s. co m * Copyright (C) 2009 Future Invent Informationsmanagement GmbH. All rights * reserved. <http://www.fuin.org/> * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.IOException; public class Main { /** * Returns the canonical file for the file without throwing a checked * exception. A potential {@link IOException} is converted into a * {@link RuntimeException} * * @param file * File to return the canonical file for or <code>null</code>. * * @return Canonical file for the given argument or <code>null</code> if the * input was <code>null</code>. */ public static File getCanonicalFile(final File file) { if (file == null) { return null; } try { return file.getCanonicalFile(); } catch (final IOException ex) { throw new RuntimeException("Couldn't get canonical file for: " + file, ex); } } }