Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileReader;
  3. import java.io.IOException;
  4. import java.io.RandomAccessFile;
  5.  
  6. public class Main {
  7.  
  8.     int funkcja(String nazwa,String szuk_nazw){
  9.  
  10.         int numer, numer_ret;
  11.         String nazwa_produktu;
  12.         double cena;
  13.         int liczba_sztuk;
  14.         String np = nazwa+".txt";
  15.         String zap ="";
  16.         try(BufferedReader file = new BufferedReader(new FileReader(np))){
  17.             RandomAccessFile zapis = new RandomAccessFile(nazwa+".wyn" , "w")
  18.             String line;
  19.             while(!((line = file.readLine())==null)){
  20.                 numer = Integer.parseInt(line);
  21.  
  22.                 line = file.readLine();
  23.  
  24.                 if(line == szuk_nazw){ numer_ret = numer}
  25.  
  26.                  nazwa_produktu= line;
  27.  
  28.                 cena = Double.parseDouble(file.readLine());
  29.                 liczba_sztuk = Integer.parseInt(file.readLine());
  30.  
  31.                 if(cena > 50 && liczba_sztuk >25){
  32.                    zap += String.valueOf(numer)+","+nazwa_produktu+","+String.valueOf(cena)+","+String.valueOf(liczba_sztuk);
  33.                    zapis.writeUTF(zap);
  34.                 }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.             } zapis.close();
  41.  
  42.  
  43.         }catch(IOException e){
  44.             e.getMessage();
  45.         }
  46.  
  47.         return numer_ret;
  48.  
  49.     }
  50.  
  51.     public static void main(String[] args) {
  52.  
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement