package project1; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import javax.swing.JOptionPane; public class SearchFile { public void SearchFile(){ byte[] infile = new byte[10000000]; File f=new File("C:\\Users\\nouryn\\Desktop\\NEW FRAME\\bank new\\BankFile.txt"); FileInputStream fin; try { fin= new FileInputStream(f); BufferedInputStream bin = new BufferedInputStream(fin); DataInputStream din = new DataInputStream(bin); try { int filelength = din.read(infile); String filestring = new String(infile, 0, filelength); // String filestring= din.readLine(); String s=JOptionPane.showInputDialog("Enter The Search Word"); int index1=filestring.indexOf(s); int indexNewLine = filestring.indexOf("\n",index1); if(index1!=-1) { JOptionPane.showMessageDialog(null,"THE NAME FOUND"); System.out.println("UR SEarRCh="+filestring.substring(index1,indexNewLine)); } else { JOptionPane.showMessageDialog(null,"NOT FOUND"); } } catch (IOException e) { // TODO } } catch (FileNotFoundException e) { // TODO } } public double SearchAccount(String s){ byte[] infile = new byte[10000000]; File f=new File("C:\\Users\\nouryn\\Desktop\\NEW FRAME\\bank new\\BankFile.txt"); FileInputStream fin; try { fin= new FileInputStream(f); BufferedInputStream bin = new BufferedInputStream(fin); DataInputStream din = new DataInputStream(bin); try { int filelength = din.read(infile); String filestring = new String(infile, 0, filelength); // String s=JOptionPane.showInputDialog("Enter The Search Word"); int index1=filestring.indexOf(s); int indexNewLine = filestring.indexOf("\n",index1); int indexNew = filestring.indexOf("=",index1); if(index1!=-1) { JOptionPane.showMessageDialog(null,"THE NAME FOUND"); System.out.println("UR SEarRCh="+filestring.substring(indexNew+1,indexNewLine)); String s1=filestring.substring(indexNew+1,indexNewLine); // DeleteFile df=new DeleteFile(); // df.removeLineFromFile(s2); double oldCredit=Double.parseDouble(s1); Double credit= Double.parseDouble(JOptionPane.showInputDialog(" Enter the money")); double newCredit= oldCredit+credit; JOptionPane.showMessageDialog(null,"ur new money"+newCredit); String s2; s2=filestring.substring(indexNew+5,filelength); // System.out.println(s2); DeleteFile2 e=new DeleteFile2(); e.DeleteFile2(s2); return newCredit; } else { JOptionPane.showMessageDialog(null,"NOT FOUND"); return 0; } } catch (IOException e) { return 0; } } catch (FileNotFoundException e) { return 0; } } }