how to write a file to a directory in java code example Example: write file from a specific location in java File file = new File("Z:\\results\\results.txt");