Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication26;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- *
- * @author Pawel
- */
- public class JavaApplication26 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException {
- // TODO code application logic here
- funkcja("C:\\Users\\Pawel\\Desktop\\x.txt");
- }
- public static void funkcja(String lok) throws FileNotFoundException, IOException
- {
- FileReader fl = new FileReader(lok);
- int IlOsob = 1;
- int c;
- String tmp="";
- String nowy ="";
- while((c=fl.read()) != -1)
- {
- if((char)c=='\n')
- {
- IlOsob++;
- nowy+=tmp.charAt(0);
- nowy+=tmp.charAt(tmp.indexOf(" ")+1);
- nowy+='\n';
- tmp="";
- }
- else tmp+=(char)c;
- }
- if(c==-1)
- {
- nowy+=tmp.charAt(0);
- nowy+=tmp.charAt(tmp.indexOf(" ")+1);
- tmp="";
- }
- nowy = nowy.toUpperCase();
- System.out.println(nowy);
- System.out.println(IlOsob);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement