The other solution I considered was initializing FileOutputStream fos = new FileOutputStream(file);
This is a much costlier implementation than two nil pointer checks.
The warning never disappears even when I create fos before file = File.createTempFile("huf", "tmp"); as the checker does not grasp that in this case fos will have been initialized.