Error reading from file.

Discussion in 'Plugin Development' started by Razorcane, Dec 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Razorcane

    As the title implies, I'm having trouble reading from a file. I think it may have something to do with how the file is laid out, but I cannot be for certain.

    At the top, when the class is defined, I define my variables. I call a readConfig() method in the onEnable() method of my plugin, however it does not read each line, nor does it report an error. I'm thinking that perhaps it is using the variables declared when the server is started instead of the ones I load? The only possible explanation I have for this is that the variables that I declare are static, which would cause them to always be read first, hence overwriting the data loaded into them.

    NOTE: I'm using .txt configurations, not yml. I will NOT use yml under ANY CIRCUMSTANCES so please do not suggest it or even bring it up. I am merely trying to fix this problem, not cause further problems.
     
  2. Offline

    skore87

    you should use yaml :p
     
  3. why should you? sure, there's already a lib included in bukkit, but since there is no *perfect* format, why shouldn't you choose one that you like?

    BTT:
    can you post your code how you're trying to read the lines from the file? Would help to solve the problem.


    Reading file would be like this:
    PHP:
    try
    {
       
    BufferedReader reader = new BufferedReader(new FileReader("FILENAME"));
       
    String currentLine;
       while((
    currentLine reader.readLine()) != null)
       {
          
    //Do whatever with currentLine
       
    }
    }
    catch(
    IOException e)
    {
        
    e.printStackTrace();
    }
     
Thread Status:
Not open for further replies.

Share This Page