How can I disable the blue console warning that show up when I am missing a file?
For example I do a check to see if an image/file exists before loading like so:
if ((img = loadImage("file.jpg")) != null) { //check if image exists
image(img, x, y);
}
BUT I still get “The file “file.jpg” is missing of inaccessible” in the console. Since I am checking for the existence of many files and I already know they may not exist can I stop the warnings?
PS: perhaps I should mention that this is for demonstration purposes only, how to suppress output to System.err. Better check if file exists and do further processing depending on the result… See: below post from @GoToLoop
import java.io.PrintStream;
import java.io.OutputStream;
final PrintStream defaultStderr = System.err;
void setup() {
size(100, 100);
System.err.println("Disable error message now ...!");
disableErrorConsole();
// your image loading here
System.err.println("I'm not printed to error console :/");
enableErrorConsole();
System.err.println("Yay! Here we go again!");
}
void disableErrorConsole() {
System.setErr(new PrintStream(new OutputStream() {
@Override
public void write(int b) {}
}));
}
void enableErrorConsole() {
System.setErr(defaultStderr);
}