Saturday, 21 July 2012

Java program which creates file dynamically

Java program which creates file dynamically


Put Commons-io 2.3 version jar in lib folder and add to class path and then run


package com.demo;

import java.io.File;

import java.io.IOException;

public class CreateFIle{
 public static void main(String[] args) throws IOException {
 File f;
 f=new File("c:\\example" + File.separator + "kop.txt");
 System.out.println("file is "+f);
 System.out.println("check "+f.exists());
 System.out.println("create "+f.createNewFile());
 System.out.println("The absolute path of the file is: "
 +f.getAbsolutePath());  
}
}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...