daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication26;
  7.  
  8. import java.io.FileNotFoundException;
  9. import java.io.FileReader;
  10. import java.io.IOException;
  11.  
  12. /**
  13.  *
  14.  * @author Pawel
  15.  */
  16. public class JavaApplication26 {
  17.  
  18.     /**
  19.      * @param args the command line arguments
  20.      */
  21.     public static void main(String[] args) throws IOException {
  22.         // TODO code application logic here
  23.         funkcja("C:\\Users\\Pawel\\Desktop\\x.txt");
  24.     }
  25.    
  26.     public static void funkcja(String lok) throws FileNotFoundException, IOException
  27.     {
  28.      FileReader fl = new FileReader(lok);  
  29.      int IlOsob = 1;
  30.      int c;
  31.      String tmp="";
  32.      String nowy ="";
  33.      while((c=fl.read()) != -1)
  34.      {
  35.       if((char)c=='\n')  
  36.       {
  37.           IlOsob++;
  38.           nowy+=tmp.charAt(0);
  39.           nowy+=tmp.charAt(tmp.indexOf(" ")+1);
  40.           nowy+='\n';
  41.           tmp="";
  42.       }
  43.       else tmp+=(char)c;
  44.      }
  45.      if(c==-1)
  46.      {
  47.          nowy+=tmp.charAt(0);
  48.           nowy+=tmp.charAt(tmp.indexOf(" ")+1);
  49.           tmp="";
  50.      }
  51.      nowy = nowy.toUpperCase();
  52.      System.out.println(nowy);
  53.      System.out.println(IlOsob);
  54.     }
  55.    
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top