我想写一个方法,在d:/att目录下用JAVA方法按照不同的年月建立目录.例如现在是2006年10月,程序判断后就在d:/att下建立200610这个目录,如果是2006年12月就建立200612文件夹.
求助大家帮忙.

解决方案 »

  1.   

    public static SimpleDateFormat format1 = new SimpleDateFormat("yyyyMM");
    static java.util.Date sysdate = new java.util.Date();
    File xmld= new File("d:\\att\\"+format1.format(sysdate));
    if(!xmld.exists()){
       xmld.mkdir();//建立目录
    }
      

  2.   

    1。新建目录<%@ page contentType="text/html;charset=gb2312"%>
    <%
    String filePath="c:/aaa/";
    filePath=filePath.toString();//中文转换
    java.io.File myFilePath=new java.io.File(filePath);
    if(!myFilePath.exists())
    myFilePath.mkdir();
    %>  2。新建文件<%@ page contentType="text/html;charset=gb2312"%>
    <%@ page import="java.io.*" %>
    <%
    String filePath="c:/哈哈.txt";
    filePath=filePath.toString();
    File myFilePath=new File(filePath);
    if(!myFilePath.exists())
    myFilePath.createNewFile();
    FileWriter resultFile=new FileWriter(myFilePath);
    PrintWriter myFile=new PrintWriter(resultFile);
    String strContent = "中文测试".toString();
    myFile.println(strContent);
    resultFile.close();
    %>