error in processing ide for code shown.

edited October 2015 in Questions about Code

Hi any help for this one would be much appreciated. ive obv picked up some kind of bad programming habit in learning at home as i get alot of null pointers, i know now why most of the time, but for some reason i just dont get why for this

BufferedReader RootDIRcontentExtractor;
PrintWriter DIR_Line_Extracted_Output;
int n=1;
String[] Ext=new String[2];
long[] NumberOfFilesofExt;
Boolean[] UserPressedButton;
long[] Number_of_inner_directories;
int k;
String line;
StringList[] LineIndexed;
String[] pieces=new String[100];
void setup(){
size(1200,1200);

Ext[0]="exe";
Ext[1]="txt";
RootDIRcontentExtractor=createReader("C:/Users/Adam/Desktop/MAIN/LEVEL1/ROOT_DIR_LEVEL1_NAMES.txt");  
DIR_Line_Extracted_Output=createWriter("C:/Users/Adam/Desktop/MAIN/output1.txt");

}

void draw(){

 try {




    line= RootDIRcontentExtractor.readLine();
    LineHasText(line);
  } catch (IOException e) {
    e.printStackTrace();
    line = null;
  }
  if (line == null) {
    exit(); 
  } else {
   for(int j=0;j<=line.length();j++){ 

    pieces = split(line," ");
    n=pieces.length;   
   for(int i=0;i<=n-1;i++){  
   LineIndexed[j].append(pieces[i]);


    DIR_Line_Extracted_Output.println(LineIndexed[j]);
   }
   }
  }

}

this output was:

forum

i will have a go in cmd,exe in evevalted mode and try assigning a label to the C drive, there isnt any harm in me doing this, right? i mean i can only assume that its mentioned in the verbose because its related, learning how to do all this stuff is already mind rapey at 32, it would be pure evil if they just threw unrelated commentary into the output so yea its safe to assume it wants me to label the drive, although im still not entirely clear on what that means. right?

Answers

  • Answer ✓

    I'm getting the hunch that Windows cannot use forward slashes ('/'). Try replacing them with backslashes, instead.

  • yea thanks it does change the verbose error i get mucking with that in the file path, ill see how white space separation goes as its worked for me before i think, i mean i only know how to write in 3 platforms half decently, and i dont run anything im writing on notepad++ i just use that one because its multilingual ( hmm maybe spell fail)

  • ok ive made some alterations and the null pointer is not an out of bounds exception, so if my experience so far is any indicator its something annoying involving the nested for loops any way this is its update

    BufferedReader RootDIRcontentExtractor;
    PrintWriter DIR_Line_Extracted_Output;
    int n=1;
    String[] Ext=new String[2];
    long[] NumberOfFilesofExt;
    Boolean[] UserPressedButton;
    long[] Number_of_inner_directories;
    int k;
    String line;
    StringList[] LineIndexed;
    String[] pieces=new String[100];
    
    void setup(){
    
    size(1200,1200);
    
    Ext[0]="exe";
    Ext[1]="txt";
    RootDIRcontentExtractor=createReader("C:/Users/Adam/Desktop/MAIN/LEVEL1/ROOT_DIR_LEVEL1_NAMES.txt");  
    DIR_Line_Extracted_Output=createWriter("output1.txt");
    
    }
    
        void draw(){
    
         try {
    
    
    
    
            line= RootDIRcontentExtractor.readLine();
            LineHasText(line);
          } catch (IOException e) {
            e.printStackTrace();
            line = null;
          }
          if (line == null) {
            exit(); 
          } else {
           for(int j=0;j<=line.length();j++){ 
            LineIndexed=new StringList[j]; 
            pieces = split(line," ");
    
           for(int i=0;i<=pieces.length-1;i++){  
    
           LineIndexed[j].append(pieces[i]);
    
    
            DIR_Line_Extracted_Output.println(LineIndexed[j]);
           }
           }
          }
    
        }
    
  • oh, i forgot to post this bit originally if im making heads scratch unnecessarily

    void LineHasText(String s){
    
    if(s.length()==0){
    print("LINE EMPTY");
    exit();
    }else{
    println(s);
    }
    
    }
    
  • Answer ✓

    First, I wonder why you read and write the files 60 times per second. In other words, why did you put the code doing I/O in draw()?

    Second, MenteCode is wrong here, Windows supports well forward slashes.

    Third, well, it is a bit strange. Is there a line highlighted when you get this error?

  • Yes well im self learnt so i get the same thing in other science stuff i usually find my way to the mark but its usually over complicated by a few million silly habits i built up eg do not know the term MenteCode so very much appreciated i know what im reading about this afternoon cheers!!!

  • i dont understand i thought being inside the catch allowed to to be in either

  • oh shit right sorry thats the user before name! i thought it was and actually new encoding system / language i had never heard of. does happen what seems to be heaps lol

  • hmmm explain how you got to 60 times per second from what i posted i dont see where ive declared that

  • Answer ✓

    Anything in draw() is executed at the sketch frame rate which by default is 60fps...

  • ok thanks much appreciated

Sign In or Register to comment.