Directory tempDirectory = Directory.directoryPath(tempDirPath).asDirectory();
WritableFile writableFile = FileFactory.filename(tempFilename).asWritableFile(tempDirectory, true);
writableFile.writeln("Test writing to file");
writableFile.writeln("row 2");
ClosedFile closedFile = writableFile.close();
System.out.println("Created file '" + tempFilename + "' in directory '" + tempDirPath + "'.");
return closedFile;
}