4:21 am - Friday April 28, 2017

To write the file in specified directory

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

 

This tutorial explains how To write the file in specified directory,Just put the full directory location in the File object.

 


import java.io.File;

public FileDirectory

{

public static void main(String[] args)

{

String dirName = "/home/mathan/Pictures";

String fileName = "rest.txt";

File dir = new File (dirName);

File actualFile = new File (dir, fileName);

System.out.println(actualFile);

}

}

 

Output

/home/mathan/Pictures/rest.txt

BACK

Filed in: Java Examples

Comments are closed.