標籤:cti flush 沒有 nec uid 建立 stream 編碼 request
屬性 |
方法 |
擷取根目錄 |
request.getServletContext().getRealPath("/"); |
建立目錄 |
File file= new File(path); if(!file.exists()){ file.mkdirs(); } |
寫檔案 |
File file =new File("檔案路徑"); OutputStreamWriter osw =new OutputStreamWriter(new FileOutputStream(file,"是否追加"),"字元編碼"); osw.write("寫入內容"); osw.flush(); osw.close(); |
讀檔案 |
File file =new File("檔案路徑"); InputStreamReader isr=new InputStreamReader(new FileInputStream(file),"字元編碼"); StringBuider sb= new StringBuider(); while(isr.ready()){ sb.append((char)isr.read()); } isr.close(); |
刪除檔案 |
File file =new File("path");//有沒有引號 file.delete(); |
靜態化技術 |
URL url =new URL ("htpp://www.rsseasy.com"); HttpURLConnection connection =(HttpURLConnection)url.openConnection(); BufferedReader in =new BufferedReader(new InputStreanReader(connection.getInputStream(),"utf-8")); StringBuffer buffer =new StringBuffer(); String line = ""; while((line=in.readLine())!=null){ buffer.append(line); } File file =new File("path"); OutputStreamWrite osw =new OutputStreamWrite(new FileOutputStream(file,file),"utf-8"); osw.write(buffer.toString()); osw.flush(); osw.close(); |
d
jsp檔案系統