Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

creating files in directory  RSS feed

 
sanj singh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
How can I create files e.g. page1.html,page2.html etc. using a for loop in a particular directory.
regards
sanj
 
amudha chinnaswamy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
class FileDemo{
public static void main(String[]args){
try{
for(int i=0;i<5;i++){
FileWriter out = new FileWriter("d://html/Page"+i+".html");
out.write("Test Report");
out.close();
}
}catch(Exception e){
System.out.println("Exception");
}
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!