I have copied this code from hackerrank. It is working correctly when I run this kind of code (this kind of means, used the System.getenv("OUTPUT_PATH") keyword) but I copy this code to my pc and tried to run that code.
But I got the error which is below. Is this System.getenv("OUTPUT_PATH") keyword working only in Hackerrank? I know how to print to a textfiles using buffered writer class but I can't understand about this code line.
Please help me to improve my knowledge.
public static void main(String[] args) throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
        String s = "Hello world";
        bw.write(s);
        bw.newLine();
        bw.close();
    }
I see this code in more hackerrank problems and I need to know why we use this... this is the error message,
Exception in thread "main" java.lang.NullPointerException
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:226)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:124)
    at java.base/java.io.FileWriter.<init>(FileWriter.java:66)
    at com.company.Main.main(Main.java:8)
 
    