Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dogadjaji;
- import grafika.Prozor;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedReader;
- import java.io.DataInputStream;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.InputStreamReader;
- import java.lang.reflect.Array;
- import javax.swing.JOptionPane;
- public class Oslus implements ActionListener
- {
- Prozor p1;
- String unos,strRed;
- String [] redovi;
- String izlaz ="";
- int status =0;
- int aa=0;
- public void actionPerformed(ActionEvent dog)
- {
- try {
- Odradi();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public Oslus(Prozor _p1) throws Exception
- {
- p1 = _p1;
- }
- private void Odradi() throws Exception
- {
- FileInputStream fstream = new FileInputStream("asoc.lst");
- DataInputStream in = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- unos = p1.unos.getText();
- if(unos.isEmpty() == true)
- {
- JOptionPane.showMessageDialog(p1,"Niste uneli rec za obradu!");
- }
- else
- {
- izlaz = "";
- p1.resenje.setText("");
- unos = unos.toUpperCase();
- while((strRed = br.readLine()) != null)
- {
- //aa++;
- //System.out.println(aa);
- strRed = strRed.toUpperCase();
- redovi = strRed.split(",");
- status = 0;
- //System.out.println(redovi[0]);
- for(int i=0; i<4; i++)
- {
- if(unos.equals(redovi[i]))
- {
- status = 1;
- break;
- }
- }
- if(status == 1)
- {
- //System.out.println(redovi[4]);
- izlaz += redovi[4] + "\n";
- status = 0;
- }
- }
- if(izlaz.equals("") == true)
- {
- JOptionPane.showMessageDialog(p1,"Ne asocira me ni na sta!");
- }
- p1.resenje.setText(izlaz);
- br.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement