java files

How to write to a file in java

public class FileWriter extends OutputStreamWriter
Convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream.
Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileWriter (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.

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

public void write(String str,int off,int len)
throws IOException

Writes a portion of a string.
Overrides:
write in class Writer
Parameters:
str – A String
off – Offset from which to start writing characters
len – Number of characters to write
Throws:
IOException – If an I/O error occurs

package com.candidjava.file;

import java.io.FileWriter;

public class JavaFileWrite {
  public static void main(String[] args)throws Exception {
    FileWriter fw=new FileWriter("F:/Files/write.txt");
    fw.write("Welcome to Candid Java");
    fw.close();
    System.out.println("File write completed successfully");
  }

}