problems with static variables and methods
Ok, so I have a loop in my constructor that sets 5 variables with unique Strings every time it loops. I need to run those 5 variables through a couple of methods which decide whether to print the variables to a txt file or not.
My problem is that the loop is apparently a static context, and I can't make the methods static. Is there any way to make this work short of taking the code out of the method and putting it directly in the loop?
Thanks.
ok, well I'll try to cut it down some
try {
fileFound = true;
BufferedWriter out = new BufferedWriter(new FileWriter("Error Logs\\" + namefile + " error log.txt"));
// open the file and read the lines
br = new BufferedReader(new FileReader(newFile));
lines = new BufferedReader(new FileReader(newFile));
int length = 0;
while(lines.readLine() != null){
length++;
}
String readline = "";
String id = "";
String client = "";
String description = "";
Boolean entry = false;
String taskCode = "";
String activityCode = "";
readline = br.readLine();
int line = 0;
ArrayList<String> variables = new ArrayList<String>();
while(line < length){
readline = br.readLine();
if(readline.contains("</TABLE>") || readline.contains("/HTML"))
break;
if(readline.contains("#000000\">")){
int i = 0;
variables.clear();
while(i<5){
int tagIndex = readline.indexOf("#000000\">") + 1;
readline = readline.substring(tagIndex);
variables.add(readline.substring(8, readline.indexOf("<")));
i++;
}
i = 0;
while(i<5){
String variable = variables.get(i).toString();
if(variable.contains("L") || variable.contains("E")){
if(variable.length() == 4){
taskCode = variable;
}
}
if(variable.contains("A") && variable.length() == 4)
activityCode = variable;
if(variable.contains("-"))
id = variable;
if(variable.contains(",")){
int j = 0;
int spaces = 0;
while(j < variable.length()){
if(variable.charAt(j) == ' '){
spaces++;
j++;
}
else
j++;
}
if(spaces >= 3)
description = variable;
else
client = variable;
}
i++;
}
}
//The previous code provides the client, description, taskCode, activityCode, and id variables, now it checks them for accuracy
RunMethod.aABAChecker(activityCode, taskCode, description);
RunMethod.anoABAChecker(activityCode, taskCode, description);
line++;
}
}
catch (IOException e) {
return;
}
public void eABAChecker (String ecode, String eDescription) throws IOException{
BufferedReader lines = new BufferedReader(new FileReader("Client Filters\\ABA Codes\\" + ecode + ".txt"));
BufferedReader ecodereader = new BufferedReader(new FileReader("Client Filters\\ABA Codes\\" + ecode + ".txt"));
int linenumber = 0;
while(lines.readLine() != null){
linenumber++;
}
boolean contains = false;
for(int l = 0; l < linenumber; l++){
if(eDescription.contains(ecodereader.readLine()))
contains = true;
}
if(contains == false)
eError = ecode;
}
public void enoABAChecker (String ecode, String eDescription) throws IOException{
BufferedReader lines = new BufferedReader(new FileReader("Client Filters\\ABA Codes\\" + ecode + ".txt"));
BufferedReader ecodereader = new BufferedReader(new FileReader("Client Filters\\ABA Codes\\" + ecode + ".txt"));
int linenumber = 0;
while(lines.readLine() != null){
linenumber++;
}
boolean contains = false;
for(int l = 0; l < linenumber; l++){
if(eDescription.contains(ecodereader.readLine()))
eError = ecode;
}
}
my constructor is RunMethod
The error was when I tried to call the methods. can't call nonstatic method in static context