summaryrefslogtreecommitdiffstats
path: root/Java/Label.java
blob: 740f8e153c8b2fdee200bffc526e9136465ec4ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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();

}
}