Java String Shorten shortenFileName(String text, String filename)

Here you can find the source of shortenFileName(String text, String filename)

Description

shorten File Name

License

Open Source License

Declaration

static public String shortenFileName(String text, String filename) 

Method Source Code

//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;
    }
}

Related

  1. shortenCount(final long count)
  2. shortenCount(int count)
  3. shortenDbName(String dbName, int desiredLength)
  4. shortenDerivedIdentifier(final String derivdedIdentifier)
  5. shortenFileName(String name)
  6. shortenGeneratedIdentifier(final String name)
  7. shortenHash(String s)
  8. shortenLabel(String key)
  9. shortenMiddle(String msg, int maxLen)