So I have this code where it prompts the user to type in a file name for the input file and the file name for the output file. I have a string called 'names' which will then be stored into the input file that was created by the user. I've got this part down.
import com.sun.org.apache.xpath.internal.SourceTree;
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
FileWriter writer = new FileWriter(chooseFile("input"));
FileWriter writer2 = new FileWriter(chooseFile("output"));
String separator = String.format("%n");
for(String name: names){
writer.write(name);
writer.write(separator);
}
}
}
public static File chooseFile(String type) {
String fname = null;
}
return file;
}
}
Something like so should modify your names list to all caps.
for (int i = 0; i < names.length; i++) {
names[i] = names[i].toUpperCase();
// writer2.write(names[i]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.