'What file extensions can be created/written with Java's Writer write() method?

I have a question about Java streams but I can't seem to find the answer in the documentation: What file formats or extensions can be written with java.io FileWriter inherited method write()? Does it depend on the platform?

I've tested writing some files like txt, doc, html, rtf, xml, sql & csv alright so far, but I'm wondering what else can be written and what cannot.

Thank you very much for your help!



Solution 1:[1]

FileWriter writes text, so that's the only restriction.

FileWriter is meant for writing streams of characters. For writing streams of raw bytes, consider using a FileOutputStream.

You can, of course, write files with any extension you like, or no extension at all. They just might not be valid files for the format.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Louis Wasserman