Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileWriter;
- import java.io.PrintWriter;
- import java.util.Scanner;
- public class Labels1 {
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- Scanner fin=null; ////////
- String input;
- PrintWriter fout = null; ////////
- String output;
- String temp; ////////
- 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 FileWriter(output),true);
- }
- catch (Exception e)
- {
- System.out.println("we have problems");
- }
- while (fin.hasNextLine())
- {
- temp = fin.nextLine();
- System.out.println(temp.length());
- System.out.print(temp.substring(0,24));
- System.out.println();
- fout.print(temp.substring(0,24));
- if (temp.substring(44,45).equals(" "))
- {
- System.out.print(temp.substring(24,44));
- System.out.println();
- }
- else
- {
- 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");
- }
- fin.close();
- fout.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement