import java.io.*; import java.util.*; public class changeFile{ public static void main(String[] args) throws IOException{ //writes contents of inputFile to outputFile, replaces all 'g' characters with 't' String inputFile = args[0]; String outputFile = args[1]; String output = new String(); BufferedReader reader = new BufferedReader(new FileReader(inputFile)); String temp; while((temp = reader.readLine()) != null){ for(int x = 0; x < temp.length(); x++){ char c = temp.charAt(x); if(c == 'g') c = 't'; output += c; } output += '\n'; } reader.close(); /*Scanner sc = new Scanner(new File(inputFile)); while(sc.hasNextLine()){ String temp = sc.nextLine(); for(int x = 0; x < temp.length(); x++){ char c = temp.charAt(x); if(c == 'g') c = 't'; output += c; } output += '\n'; }*/ BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile)); writer.write(output); writer.close(); } }