diff options
author | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
commit | 9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch) | |
tree | eb1efc1d028b949dd83bb710c68be8eff58f26e7 /Java/Label2.java | |
download | school-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.tar.gz school-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.tar.bz2 school-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.zip |
Diffstat (limited to 'Java/Label2.java')
-rw-r--r-- | Java/Label2.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Java/Label2.java b/Java/Label2.java new file mode 100644 index 0000000..5a34aee --- /dev/null +++ b/Java/Label2.java @@ -0,0 +1,36 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; +import java.util.ArrayList; + +public class Label2{ +public static void main(String[] arg) throws IOException{ +Scanner user_in = new Scanner(System.in); + +System.out.println("Enter input file:"); +String input_filename = user_in.nextLine(); +System.out.println("Enter output file:"); +String output_filename = user_in.nextLine(); + +File input_file = new File(input_fname); +Scanner file_in = new Scanner(input_file); + +List<String> people_data = new ArrayList<String>(); +while(file_in.hasNextLine()){ +people_data.add(file_in.nextLine()); +} + +File output_file = new File(output_fname); +FileWriter writer = new FileWriter(output_file); +for (int i = 0; i < people_data.size(); i++) { + String[] datas = people_data.get(i).split(","); + if(datas[j].length() > 0){ + writer.write(datas[j] + "\n"); + } +} +writer.write(datas[3] + ", " + datas[4] + " " + datas[5] + "\n\n"); + +writer.close(); +}} |