Here you can find the source of getFilename(File file)
public static String getFilename(File file)
//package com.java2s; /*/*from w w w .j a va 2s .c o m*/ * Copyright 2007, 2012 Stephen Fisher and Junhyong Kim, University of * Pennsylvania. * * This file is part of Glo-DB. * * Glo-DB is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Glo-DB 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Glo-DB. If not, see <http://www.gnu.org/licenses/>. * * @(#)GUIUtils.java */ import java.io.File; public class Main { /** * On Windows machines the path contains "\\", however, when * converted to a String, this becomes "\". So we are doubling * them here, to preserver the "\\". */ public static String getFilename(File file) { return file.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\"); } }