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/Label.java | |
download | school-code-master.tar.gz school-code-master.tar.bz2 school-code-master.zip |
Diffstat (limited to 'Java/Label.java')
-rw-r--r-- | Java/Label.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Java/Label.java b/Java/Label.java new file mode 100644 index 0000000..740f8e1 --- /dev/null +++ b/Java/Label.java @@ -0,0 +1,35 @@ +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; + +public class Label{ +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 inputFile = new File(input_filename); +Scanner file_scanner = new Scanner(inputFile); + +String[] person_data = new String[6]; +for(int i = 0; file_scanner.hasNextLine(); i++){ +person_data[i] = file_scanner.nextLine(); +} + +File outputFile = new File(output_filename); +FileWriter writer = new FileWriter(outputFile); +writer.write(person_data[0] + "\n"); +writer.write(person_data[1] + "\n"); +if(person_data[2].length() > 0){ +writer.write(person_data[2] + "\n"); +} + +writer.write(person_data[3] + ", " + person_data[4] + " " + person_data[5]); +writer.close(); + +} +} |