#Problem with netbeans when reading args passed through console
1 messages · Page 1 of 1 (latest)
<@&987246527741304832> please have a look, thanks.
I get the string corresponding to the file like this ```
args[0]
the screenshot is barely readable. its extremely small
sec
that said, it looks like u passed it correct
so it would be nice to see why u think its not working
basically
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;
}
}
Detected code, here are some useful tools:
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;
}
}
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;
}
}
}
Detected code, here are some useful tools:
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?
If it's unrelated, and maybe you didn't compile again?
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