Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class raf {
- static String apteka(String plik) throws FileNotFoundException{
- int porown = 9999;
- String najtanszy = " ";
- try{
- RandomAccessFile raf = new RandomAccessFile(plik, "rw");
- String line;
- while( (line = raf.readLine())!= null){
- String lek = line;
- long pos1 = raf.getFilePointer();
- int cena = Integer.parseInt(raf.readLine());
- Boolean refund = Boolean.parseBoolean(raf.readLine());
- long pos2 = raf.getFilePointer();
- if(refund) {
- raf.seek(pos1);
- raf.writeBytes(Long.toString(Math.round(cena*0.85)));
- String cenaxd = Long.toString(Math.round(cena*0.85));
- cena = Integer.parseInt(cenaxd);
- raf.seek(pos2);
- }
- if(cena<porown){
- porown=cena;
- najtanszy=lek;}
- }
- }
- catch(Exception e){System.out.println(e);}
- return najtanszy;}
Add Comment
Please, Sign In to add comment