Here you can find the source of filePathGen(String oldPath, String newExtension, String newFileName)
Parameter | Description |
---|---|
oldPath | a parameter |
newExtension | a parameter |
newFileName | a parameter |
public static String filePathGen(String oldPath, String newExtension, String newFileName)
//package com.java2s; //License from project: Open Source License public class Main { /**/*w ww. jav a 2s . c o m*/ * Create a copy of a file in same directory but can rename and change it's * extension * * @param oldPath * @param newExtension * @param newFileName * @return String newPath */ public static String filePathGen(String oldPath, String newExtension, String newFileName) { if (newFileName.contains(".")) { newFileName = newFileName.substring(0, newFileName.lastIndexOf('.')); } if (newExtension.charAt(0) != '.') { newExtension = "." + newExtension; } String newPath = ""; if (newFileName != null) { newPath = oldPath.substring(0, oldPath.lastIndexOf('\\') + 1) + newFileName + newExtension; } else { newPath = oldPath.substring(0, oldPath.lastIndexOf('.')) + newExtension; } return newPath; } }