Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: What's wrong with my codes?

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Thanked 0 Times in 0 Posts

    Question What's wrong with my codes?

    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) {

    } 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);
    System.out.println("Create success!");

    }catch (Except e)



  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,627 Times in 2,577 Posts

    Default Re: What's wrong with my codes?

    I can't input a txt with this program
    Please explain. What happens when the code is compiled and executed?

    Please edit your post and wrap your code with code tags:


    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: March 9th, 2018, 04:34 AM
  2. whats is wrong in this codes ? output
    By joseph07 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 2nd, 2014, 07:26 AM
  3. Replies: 3
    Last Post: November 26th, 2013, 06:41 AM
  4. Help me please with my codes
    By sara92 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 12th, 2012, 11:52 AM
  5. Please Help What's Wrong with my Codes!
    By bertzki10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 25th, 2011, 11:03 AM