Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.PrintWriter;
- import java.util.Scanner;
- public class Labels {
- public static void main(String[] args) {
- /////////////////////This version does not have the fout statements. You must add them beginning with substring(0,24)
- Scanner kb = new Scanner(System.in);
- Scanner fin=null; ////////
- String input;
- PrintWriter fout = null; ////////
- String output;
- String temp=null; ////////
- System.out.println("What is the name of the file?");
- input = kb.nextLine();
- System.out.println("What is the name of the output file?");
- output = kb.nextLine();
- try {
- fin = new Scanner(new File(input));
- fout = new PrintWriter(new File(output));
- }
- catch (Exception e)
- {
- System.out.println("we have problems");
- }
- while (fin.hasNextLine())
- {
- temp = fin.nextLine();
- System.out.print(temp.substring(0,24));
- System.out.println();
- if (temp.substring(44,45).equals(" ")) // assuming you left address2 blank
- {
- System.out.print(temp.substring(24,44));
- System.out.println();
- }
- else // assuming you had an address 1 and 2
- {
- System.out.print(temp.substring(24,44));
- System.out.println();
- System.out.print(temp.substring(44,64));
- System.out.println();
- }
- System.out.print(temp.substring(64,84).trim()+ ", ");
- System.out.print(temp.substring(84,86) + " ");
- System.out.print(temp.substring(86));
- System.out.println("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement