Here you can find the source of appendToFileName(File file, String str)
public static File appendToFileName(File file, String str)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static File appendToFileName(File file, String str) { String properPath = file.getPath().substring(0, file.getPath().lastIndexOf(File.separator)); String fileNameWithoutExt = file.getName().substring(0, file.getName().lastIndexOf(".") == -1 ? file.getName().length() : file.getName().lastIndexOf(".")) + str.replaceAll("\\s", "_"); return new File((properPath + File.separator + fileNameWithoutExt + ".srt")); }//w w w. j av a2 s. c om }