Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:15:42+00:00 2026-06-15T15:15:42+00:00

I have been writing a Java program – Specifically a Bukkit plugin, although that

  • 0

I have been writing a Java program – Specifically a Bukkit plugin, although that has nothing to do with the question – and for a reason I cannot see I am getting a NullPointerException. Excerpted below is the code at which there is an error. getPath() is well-tested and yields the correct directory – That is, the one in which the config file should be in. the config file is created, and should have been written to. The tester file I have has been successfully created, and so should the config file.

File config = new File(getPath("config"));
BufferedReader in = new BufferedReader(new FileReader(config));
skipLines(11, in);
if(in.readLine().equalsIgnoreCase("true")) {   //Exception is here
    System.out.println("Successfully wrote to config file");
}
else {
    System.out.println("Failed to write text correctly to config file");
}
in.close();

The whole thing is enclosed in a try/catch statement.
If you need any more info, just ask and I will be happy to provide.
NOTE: The file is working just fine – When I check manually the file has writing on it. That’s why the problem exists.
The code that writes to the file is below:

File exConfig = new File(System.getProperty("user.dir") + File.separator + "configExample");
PrintWriter out = new PrintWriter(new FileWriter(config));
BufferedReader in = new BufferedReader(new FileReader(exConfig));
for(int i = 1; i <= configLength; i++) {
    out.println(in.readLine());
}
out.flush();
out.close();
System.out.println("Successfully wrote defaults to config");

configLength is a variable equal to the number of lines in the config. I have tested it and it works.
There may be something odd there. The file called “configExample” is as follows:

########################################
#  hPlugin is written by newbiedoodle  #
########################################
#   -----  Plugin config file  -----   #
########################################
hPlugin
v.0.3
NOTE: Do not edit the config file besides changing the values - it may result in errors.
--------------
Enable hPlugin?
true
Strikes before being banned?
3
Godmode?
true
First time running the plugin?
true
Curse protection?
true
Emergency shelter?
true
Path building?
true
Blocked words/phrases (Separate with colon (:)):
shit:fuck:damn:bitch:hell

As you can see, this SHOULD be more than 11 lines… And if the 11th line isn’t “true” then it still shouldn’t cause an error.

Well, after a little bit of fooling around, I got it to work… Turns out, I had a variable screwed up because a function had a filename hard-coded into it rather than set to the variable I was trying to pass. Thanks for all the help though!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:15:43+00:00Added an answer on June 15, 2026 at 3:15 pm

    The exception is obvious, there is nothing to read from your BufferedReader. Thus in.readLine() returns null, Thus invoking in.readLine.equalIgnorecase() returns NullPointerException.

    you should first check if BufferedReader.readLine() returns null, before you proceed.

    if(in.readLine().equalsIgnoreCase("true")) {   //Exception is here
    

    should be

    String line=null;
    while((line=in.readLine())!=null) {   //if in.readLine()  returns null, the condition fails
    if(line.equalsIgnoreCase("true")) {
         //do your stuff
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing a small java application (my first!), that does only a
I have been writing a program that watches a directory and when files are
So I have been tasked with writing a program that determines if a number
I have been working on writing a Java program to convert from infix notation
I have been writing DLL on C++, that will be use in C#. DLL
Alright, so I'm writing this program that essentially batch runs other java programs for
I have a simple Java program that takes a .jrxml file, compiles it, then
I'm writing a Java program where I have to extract some data from a
I've been writing a program that can determine any and every data about an
I'm writing my 1st Java program (in Netbeans) and I'm lost. I have 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.