Here you can find the source of shortenFileName(String text, String filename)
static public String shortenFileName(String text, String filename)
//package com.java2s; /* Copyright 2012, UCAR/Unidata. See the LICENSE file for more information. *///from w w w . jav a 2 s .c om public class Main { static public String shortenFileName(String text, String filename) { // In order to achieve diff consistentcy, we need to // modify the output to change "netcdf .../file.nc {...}" // to "netcdf file.nc {...}" String fixed = filename.replace('\\', '/'); String shortname = filename; if (fixed.lastIndexOf('/') >= 0) shortname = filename.substring(fixed.lastIndexOf('/') + 1, filename.length()); text = text.replaceAll(filename, shortname); return text; } }