Advertisement
therrontelford

Label without Output

Jan 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileWriter;
  3. import java.io.PrintWriter;
  4. import java.util.Scanner;
  5.  
  6. public class Labels1 {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner kb = new Scanner(System.in);
  10.         Scanner fin=null; ////////
  11.         String input;
  12.         PrintWriter fout = null; ////////
  13.         String output;
  14.         String temp;  ////////
  15.         System.out.println("What is the name of the file?");
  16.         input = kb.nextLine();
  17.         System.out.println("What is the name of the output file?");
  18.         output = kb.nextLine();
  19.        
  20.         try {
  21.         fin = new Scanner(new File(input));
  22.         fout = new PrintWriter(new FileWriter(output),true);
  23.         }
  24.         catch (Exception e)
  25.         {
  26.             System.out.println("we have problems");
  27.         }
  28.        
  29.         while (fin.hasNextLine())
  30.         {
  31.             temp = fin.nextLine();
  32.             System.out.println(temp.length());
  33.            
  34.                 System.out.print(temp.substring(0,24));
  35.                 System.out.println();
  36.                 fout.print(temp.substring(0,24));
  37.            
  38.             if (temp.substring(44,45).equals(" "))
  39.             {
  40.            
  41.                 System.out.print(temp.substring(24,44));
  42.                 System.out.println();
  43.            
  44.             }
  45.             else
  46.             {
  47.                
  48.                     System.out.print(temp.substring(24,44));
  49.                     System.out.println();
  50.                
  51.                
  52.                     System.out.print(temp.substring(44,64));
  53.                     System.out.println();
  54.                
  55.             }
  56.                
  57.                     System.out.print(temp.substring(64,84).trim()+ ", ");
  58.                    
  59.                
  60.                
  61.                     System.out.print(temp.substring(84,86) + "  ");
  62.            
  63.                
  64.                     System.out.print(temp.substring(86));
  65.                
  66.            
  67.                 System.out.println("\n");
  68.                
  69.            
  70.         }
  71.        
  72.         fin.close();
  73.         fout.close();
  74.        
  75.        
  76.        
  77.  
  78.     }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement