import java.io.File; public class MainClass { public static void main(String[] argv) throws Exception { String TheFile = "Program.java"; File F = new File(setFileType(TheFile)); System.out.println("Created " + TheFile); } public static String setFileType(String fname) { int p = fname.indexOf('.'); if (p > 0) fname = fname.substring(0, p); fname += ".TXT"; return fname; } }