一个文件的示例
try //谁能告诉我在这个例子中哪里是在创建文件
{
if(!(new File("D:/java/newdata/").isDirectory()))
{
new File("D:/java/newdata/").mkdir();
new File("D:/java/newdata/2003-04-14/").mkdir();
}
else
{
new File("D:/java/newdata/2003-04-14/").mkdir();
}
}
catch(SecurityException e)
{
System.out.println("can not make directory");
}
File myFile = new File("D:/java/newdata/2003-04-14/myfile.txt ");
FileOutStream fos = new FileOutStream(myFile);
用fos.write("你要写入的内容");