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;
}
}
我对线程没有清楚的了解。是否可以在此代码中实现线程?我想这个线程可以在两个类中的一个中实现。但是线程的整体概念很难理解。另外,在开发完整个代码后使用线程的功能是什么?
答案 0 :(得分:0)
由于'%'
,sql查询过早地关闭了where条件 - 将其更改为这样:
$query = "SELECT * FROM invoice
WHERE CONCAT('inv_id', 'inv_date', 'inv_details', 'client_name', 'amount', 'discount',
'total_amount', 'payment_status') LIKE '%" . $valueToSearch . "%'";