#Problem with netbeans when reading args passed through console

1 messages · Page 1 of 1 (latest)

vocal pawn
#

Hello when I try to run my application through netbeans using the configuration in the Run widget my application
doesnt recognize the arg passed as a string to a file, the reason I have to do it this way is cause in the course it was
made explicit that the application should start it through the following manner.

drowsy trenchBOT
#

<@&987246527741304832> please have a look, thanks.

vocal pawn
#

I get the string corresponding to the file like this ```
args[0]

novel marsh
vocal pawn
#

sec

novel marsh
#

that said, it looks like u passed it correct

#

so it would be nice to see why u think its not working

vocal pawn
#

basically

novel marsh
#

like, are u getting any error messages for example

#

mind sharing ur code

vocal pawn
#

one sec

#
public class InputFile {
    private File _file;
    private BufferedReader _reader;
    private Status _fileStatus;
    
    
    public InputFile(String input) throws FileNotFoundException, IOException {
        final File test = new File(input);
        this._file = new File(input);
        this._fileStatus = new Status("",statusCode.UNDEFINED);
        this._fileStatus = this._isFile();
        if(this._fileStatus.getStatusCode()==statusCode.INPUTFILEERROR){
            return;
        }
        this._InitializeReader();
    }
    
    public Status getStatus(){
        return _fileStatus;
    }
    
    private Status _isFile(){
       Status output; //new Status("",statusCode.ERROR);
       String CWD = System.getenv("CWD");
       boolean isFile = _file.isFile();
       
       if(!isFile){
           output = new Status(messages.ifem,statusCode.INPUTFILEERROR);
       } else {
           output = new Status(messages.ofem,statusCode.OK);
       }
       return output;
    }
    
    private void _InitializeReader() throws FileNotFoundException, IOException {
        _reader = new BufferedReader(new FileReader(this._file, Charset.forName("UTF-8")));
    }
    
    public BufferedReader getReader(){
        return this._reader;
    }
    
}
drowsy trenchBOT
# vocal pawn ```java public class InputFile { private File _file; private BufferedRea...

Detected code, here are some useful tools:

Formatted code
public class InputFile {
  private File_file;
  private BufferedReader_reader;
  private Status_fileStatus;
  public InputFile(String input) throws FileNotFoundException, IOException {
    final File test = new File(input);
    this ._file = new File(input);
    this ._fileStatus = new Status("", statusCode.UNDEFINED);
    this ._fileStatus = this ._isFile();
    if (this ._fileStatus.getStatusCode() == statusCode.INPUTFILEERROR) {
      return ;
    }
    this ._InitializeReader();
  }
  public Status getStatus() {
    return _fileStatus;
  }
  private Status_isFile() {
    Status output;
    //new Status("",statusCode.ERROR);
    String CWD = System.getenv("CWD");
    boolean isFile = _file.isFile();
    if (!isFile) {
      output = new Status(messages.ifem, statusCode.INPUTFILEERROR);
    }
    else {
      output = new Status(messages.ofem, statusCode.OK);
    }
    return output;
  }
  private void _InitializeReader() throws FileNotFoundException, IOException {
    _reader = new BufferedReader(new FileReader(this ._file, Charset.forName("UTF-8")));
  }
  public BufferedReader getReader() {
    return this ._reader;
  }
}
vocal pawn
#

this is wher eI handle the file

#
public class Proyecto_1_Diego_Avila {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        final int argSize = args.length;
        
        switch(argSize){
            case 1:
                InputFile file = new InputFile(args[0]);
                Tokenizer scanner = new Tokenizer(file);
                scanner.run();
                break;
            default:
                System.out.println(argSize);
                System.out.println(Utilities.mIncorrectProgramInput);
                // do something;
                break;
        }
    }
    
}
drowsy trenchBOT
vocal pawn
#

this is the entry point

#

this is how im passing the argument to the main method

#

my teachers want my solution to be executed in the following manner

#
D:\Directory_of_source_code\>java - jar Project.jar "input.py"
#

the issue is when I try to read data, I declare BufferedReader in the InputFile class

#

when I access the reader in another class I get an error telling me that the reader is null

#

weird

#

its working now

#

now I have another question should I open a new thread?

finite tiger
#

If it's unrelated, and maybe you didn't compile again?

vocal pawn
#

it was probably to do with the working directory that was being used

#

the new question is more about the strategy for doing a scanner than anything

#

like I have to do a scanner for python but I think they are also asking for some features of a parser too

#

what im worried the most right now is things to look out for when escaping characters that are nested within subtokens