Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class pesel {
- static int max = 0;
- static String maxx;
- static int doemerytury;
- static int dataa;
- static int wiek;
- static String data;
- static String fix(String filename) throws FileNotFoundException {
- try{
- RandomAccessFile raf = new RandomAccessFile(filename, "rw");
- String line;
- while( (line=raf.readLine())!=null ){
- String imie = line;
- String nazwisko = raf.readLine();
- char plec = raf.readLine().charAt(0);
- long pesel = Long.parseLong(raf.readLine());
- long pos1 = raf.getFilePointer();
- raf.writeBytes(" ");
- String pestring = Long.toString(pesel);
- String l1 = Character.toString(pestring.charAt(0));
- String l2 = Character.toString(pestring.charAt(1));
- if(pestring.length()==11){
- data = "19"+l1+l2;}
- else { data = "20"+l1+l2;}
- dataa = Integer.parseInt(data);
- wiek = 2020-dataa;
- if(plec=='K'){ doemerytury = 60-wiek; }
- if(plec=='M'){ doemerytury = 65-wiek; }
- raf.seek(pos1);
- raf.writeBytes(Integer.toString(doemerytury));
- if(doemerytury>max){maxx=imie+" "+nazwisko;}
- raf.readLine();
- }
- raf.close();
- }
- catch (Exception e){System.out.println(e);}
- return maxx;}
Add Comment
Please, Sign In to add comment