JAVA: how to query a word within a RandomAccessFile?

0

good is my first question here: I have doubts on how to make a query within a randomaccessfile. I have this part of the code the only thing that it does is that if I write the name of my first product that is in the list if it prints it, but if I look for another name that is later that tells me that the "product is not found registered "even if it is.

public void Consulta() 
{
    try
    {
        Prod=new RandomAccessFile(Catalogo.dat,rw);

        String Pro,busc;
        int Encontrado=0;
        busc=JOptionPane.showInputDialog(ingressa el nombre del producto);
        while((Pro=Prod.readLine())!=null)
        {
            if(Pro.equalsIgnoreCase(busc))
            {
                Familia=Prod.readLine();
                Marca=Prod.readLine();
                Bod=Prod.readLine();
                Precio=Prod.readFloat();

                System.out.println(nombre+Pro+n 
                        + Familia+Familia+n
                        + Marca+Marca+n
                        + Bodega+Bod+n
                        + Precio$+Precio+n);
                Encontrado++;
            }
        }
        if(Encontrado==0)
        {
            JOptionPane.showMessageDialog(null, el Producto no esta registrado);
        }
        Prod.close();
    }
    catch(FileNotFoundException e)
    {

    }
    catch(IOException e)
    {

    }
}
    
asked by Juan Carlos Tlaxcala 19.05.2018 в 01:53
source

1 answer

0

you should use the function of the string contains (busc) envez de

  

equalsIgnoreCase (busc)

    
answered by 19.05.2018 в 19:21