與我一起遨游吧
private void FileWrite(String ftp,String DXBS,String fileName,String fileExt){ java.net.URL urlfile = null; HttpURLConnection httpUrl = null; try { // 連接指定的網絡資源,獲取網絡輸入流 urlfile = new java.net.URL(ftp+"/"+DXBS+"/"+fileName+"."+fileExt); httpUrl = (HttpURLConnection) urlfile.openConnection(); httpUrl.connect(); int bytesum = 0; int byteread = 0; InputStream inStream = httpUrl.getInputStream(); this.mkdir("d:/ftp/"+DXBS); FileOutputStream fs = new FileOutputStream("D:/ftp/"+DXBS+"/"+fileName+"."+fileExt); byte[] buffer = new byte[1444]; while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; fs.write(buffer, 0, byteread); } } catch (Exception e) { } } private void mkdir(String mkdirName) throws Exception { File dirFile = new File(mkdirName); boolean bFile = dirFile.exists(); if (bFile == true) { } else { bFile = dirFile.mkdir(); if (bFile == true) { } else { System.exit(1); } } } 大家看代碼,第一個方法是讀取遠程的文件,生成同樣的目錄文件,下面的方法是生成文件夾
posted on 2007-06-25 13:39 imcb 閱讀(630) 評論(1) 編輯 收藏
參數還是應該說明一下 回復 更多評論
Powered by: BlogJava Copyright © imcb