A newLine() method is provided, which uses the platform's own notion of line separator as defined by the system property line.separator. Not all platforms use the newline character ('\n') to terminate lines. Calling this method to terminate each output line is therefore preferred to writing a newline character directly, FileWriter doesn't have this feature. ALso BufferedWriter are fast as they write to buffer first before writing to file
Chat with our AI personalities
// to create a new file File f = new File("newfile.txt"); f.createNewFile(); // to write a string to a file String str = "This text will appear in newfile.txt\nThis, too."; // create our writer object BufferedWriter out = new BufferedWriter(new FileWriter(f)); // write str to f out.write(str); // remember to flush the buffer and close the writer out.flush(); out.close();
Unix is an operating system, Java is a language.
Rowset
difference between constant and static variables in java
Java or Java SE comes with the standard library, with all the crazy classes to make life easy. Java Core does not come with most of these classes, so that it is a lot smaller.