This is the goal I want to achieve:
As soon as I write the text in a csv file and save it, processing will display it instantly.
But now, if I save the csv file while running the code, Error will show up.
Here is the code:
Table table;
void setup() {
}
void draw(){
table = loadTable(“input.csv”, “header”);
for (TableRow row : table.rows()) {
int id = row.getInt(“id”);
String species = row.getString(“species”);
String name = row.getString(“name”);
println(name + " (" + species + ") has an ID of " + id);
}
}
And the Error:
java.io.IOException: 程序無法存取檔案,因為另一個程序已鎖定檔案的一部分。
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:276)
at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:282)
at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270)
at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313)
at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
at java.base/java.io.BufferedReader.fill(BufferedReader.java:162)
at java.base/java.io.BufferedReader.read(BufferedReader.java:183)
at processing.data.Table.parse(Table.java:398)
at processing.data.Table.(Table.java:168)
at processing.core.PApplet.loadTable(PApplet.java:5721)
at sketch_221020a.draw(sketch_221020a.java:24)
at processing.core.PApplet.handleDraw(PApplet.java:2131)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1386)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
NullPointerException