anyone help me with this? This is just a simple library that I created and this is a code that where you can can search a book
package prefi;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Scanner;
public class BookFinder {
public void Search_Book() {
try {
BufferedReader br = null;
FileReader fr = null;
Scanner scan = new Scanner (System.in);
String BookName = "";
String data = "";
int count =0;
System.out.println ("Input Book Name: ");
BookName = scan.next();
fr = new FileReader (BookName+".txt");
br = new BufferedReader(fr);
while ((data = br.readLine()) !=null) {
count++;
System.out.println(count+"."+data);
}
} catch (Exception e) {
//System.out.println("Error msg"+e.getMessage());
System.out.println("Book not found!");
}
}
and I have another problem as well . I can't input a txt with this program
package prefi;
import java.io.PrintWriter;
import java.util.Scanner;
public class Generate_txt {
public static void Adding_Book() {
java.util.Scanner scan = new Scanner (System.in);
String BookTitle = " ",Section = " ",B_Author = " ";
System.out.println("BookTitle: ");
BookTitle = scan.next();
System.out.println("Section: ");
Section = scan.next();
System.out.println("Author: ");
B_Author = scan.next();
try {
PrintWriter writer = new PrintWriter (BookTitle+".txt","UTF-8");
writer.println("BookTitle: "+BookTitle);
writer.println("Section: "+Section);
writer.println("Author: "+B_Author);
writer.close();
System.out.println("Create success!");
}catch (Except e)
{
System.out.prinln(""+e.getMessage());
}
}
}