File not found in Java [duplicate]

If it is a regular file outside a .jar, you are using a relative path. That means, the path to the file is formed from the path where you are calling the file from + the relative path. To make it work, you should invoke java within src folder

C reading from file

Here’s an example of how i would implement PrintFile, hope it helps. #include <stdio.h> int PrintFile(const char *filename); int PrintFile(const char *filename) { FILE *file = fopen(filename, “r”); if (file == NULL) { return -1; } int c = 0; int i = 0; while ((c = fgetc(file)) != EOF) { if (isprint(c)) { fputc(c, … Read more