Here you can find the source of renameSuffix(File f, String suffix)
public static File renameSuffix(File f, String suffix)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static File renameSuffix(File f, String suffix) { if (null == f || null == suffix || suffix.length() == 0) return f; return new File(renameSuffix(f.getAbsolutePath(), suffix)); }/*from w w w . ja va2 s . com*/ public static String renameSuffix(String path, String suffix) { int pos = path.length(); for (--pos; pos > 0; pos--) { if (path.charAt(pos) == '.') break; if (path.charAt(pos) == '/' || path.charAt(pos) == '\\') { pos = -1; break; } } if (0 >= pos) return path + suffix; return path.substring(0, pos) + suffix; } }