-2
import java.io.*;
class FileApi extends File
{
//Variables declaration
//declare object FileWriter and FileReader

FileWriter fw;
FileReader fr;


File file;
FileApi(String s)
{
    super(s);
    file = new File(s+".txt");
}

boolean fileExists()
{
    if(file.exists())
    return true;
    else
    return false; 
}


/**
    This method is used to create a new file in the 
      current directory

*/

void createFile() throws IOException
{
    fw = new FileWriter(file);
    fw.close();
}

/**
    This method is used to write text into file

*/

void writeFile(String s)
{
    try
    {
        fw = new FileWriter(file);
        fw.write(s);
        fw.close();

    }catch(IOException asdf){
    asdf.printStackTrace();
    }
}

/**
    This method is used to read text from file

*/

String readFile() throws Exception
{
    fr = new FileReader(file);
    BufferedReader br = new BufferedReader(fr);
String data;
while((data = br.readLine()) == null)
{
System.out.println(data);
}       

fr.close();
return data;


}
}

i don't have a clear understanding on thread. is it possible to implement thread in this code? i guess that thread can be implemented in one of the two classes. but the overall concept of thread is quite difficult to understand. Plus, what is the function of using thread after u have developed the entire code?

1 Answers1

0

The sql query prematurely closes the where condition because of '%' - change it to something like this perhaps:

$query = "SELECT * FROM invoice 
    WHERE CONCAT('inv_id', 'inv_date', 'inv_details', 'client_name', 'amount', 'discount', 
   'total_amount', 'payment_status') LIKE '%" . $valueToSearch . "%'";  
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46