2014-03-12 62 views
0
<% 
     String s=request.getParameter("text1"); //text1 is textbox 
     java.io.File file = new File("c:/jk"); //location is c: 
    %> 

    <% 
    if (!file.exists()) //check if file exists 

     file.mkdirs(); 
    else 
     out.println("the file exists");   
    %><br/> 

我怎麼可以指定在運行時間,而不是JK該文件夾的名字..指定的文件夾名稱

這意味着我在text1給了一個隨機名稱和文件夾應與隨機保存名字..

回答

0
String folderName="folderName" //get this at run time 
new File("C:/" + folderName); 

這是你的方式。

0

我想你可以通過在文件中串聯一個變量,這樣做:new File("c:/" + varName)