Create FileWriter from path String and write string value to a text file - Java File Path IO

Java examples for File Path IO:Text File

Description

Create FileWriter from path String and write string value to a text file

Demo Code

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class FileWriterTest {

    public static void main(String[] args) throws IOException {
       Writer writer = null;/*w w w.j  a v a 2  s. com*/
       try{
           writer = new FileWriter("C:/output.txt");
           writer.append("from java2s.com");

       }finally{
           if(writer != null){
               writer.close();
           }
       }
    }
    
}

Related Tutorials