Was anything introduced in Java, in the last editions (1.5/1.6) that facilitate writing strings开发者_开发百科 to files (the Scanner of writing)?
Easier than FileWriter?
It's not a core library in Java but FileUtils in Apache Common IO is a useful class.
FileUtils.writeStringToFile(File file, String data );
I tend to use PrintStream
and printf
.
I don't think so, I don't imagine what the "Scanner for writing" would be - I don't see a duality there. For simple writing of text, a Writer seems enough.
If you are thinking of something like a formatter, there are good third party libraries, for example, I like Freemarker.
I find I use RandomAccessFile a lot.
RandomAccessFile rafWrite = new RandomAccessFile("<file name>", "<mode, usually rw>");
rafWrite.writeBytes("<text you want to write>");
精彩评论