How do I correctly loadStrings() from a file path on my local computer?

I have been working on reading a text file. Making progress.

However, I have encountered a problem I would like some help on. That being how do I read a text file from a folder on another part of my computer?

I am using Windows 10, so I can grab the file path from the File Explorer. However, because of the type of backslash it will not load. How should I be formatting this so it will work correctly?

Thank you!

Error code:
processing.app.SketchException: Not expecting symbol β€˜U’, which is LATIN CAPITAL LETTER U.

// Code by Casey Scalf
// Basic Display of text from .txt file

PFont f;
String lines;
String joinLines;

/////////////////////////////////////////////////////////////////////////////////////////
void setup () {

size(960, 540, P3D);
background(0);

f = createFont(β€œArial”, 24, false); // Arial, 16 point, anti-aliasing on
textFont(f);

lines = loadStrings(β€œC:\Users\Casey Scalf\Desktop\Projects\Amazon Book\Book Export\IMG_0004.txt”);
joinLines = join(lines, β€œβ€);

println(joinLines.length());
}

/////////////////////////////////////////////////////////////////////////////////////////
void draw() {

fill(220);

textAlign(LEFT);
textLeading(40);

text(joinLines, 50, height/3, width - 100, 200);
}

The fix for that is really simple: replace the backward slashes with forward slashes!

2 Likes

That worked great thank you!