I'm pretty new to Processing and Java so this is probably pretty simple. Just bear with me. It's just sliding over my head. This is the code I have
The txt file I'm pulling from consists of numbers like this:
1: 100
2: 200
3: 300 etc.
void setup() {
size(200,200);
String[] lines = loadStrings("WordFrequency.txt");
lines = lines.replaceAll(":", ",");
lines = lines.replaceAll(" ", ",");
}
}
Adding to Kevin's answer for replacing new line character. replace
will not work because you have already parsed the new line characters while parsing the file into an array of strings.
You should append the strings after replace. Something like this:
String fileString = "";
for(int i = 0; i < lines.length; i++){
lines[i] = lines[i].replace(":", ",");
lines[i] = lines[i].replace(" ", ",");
fileString += lines[i];
}