Problem with loadStrings file.txt
in
Programming Questions
•
1 year ago
Can't seem to get loadStrings to successfully access a text file located in the data directory of the sketch. I receive the
error message:
The file "source.txt" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Exception in thread "Animation Thread" java.lang.NullPointerException
at sketch_nov28_text_import.draw(sketch_nov28_text_import.java:49)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
I am using Ubuntu and have double-checked not only the location of the file but also the permissions. I am not sure whether the error is in my code or in the permissions. Any advice would be helpful.
--------------------------
String coal_a[] = loadStrings("source.txt");
/*String coal_a[] = {"one",
"two",
"three",
"four",
"five",
"six",
"seven"}
*/
PFont font;
int y = 320;
int m;
int v=0;
int margin = 10;
void setup() {
size(500, 500);
font = loadFont("ForgottenFuturist-48.vlw");
textFont(font);
}
void draw() {
background(0);
textFont(font);
textSize(40);
fill(193);
for (int i=0; i < coal_a.length; i++) {
text(coal_a[i], 100, 20+i*20);
}
}
2