我的空間,寫(xiě)我所寫(xiě),禪我所藏

          與我一起遨游吧

           

          讀取遠(yuǎn)程文件,然后在指定目錄下生成同樣的文件

          private void FileWrite(String ftp,String DXBS,String fileName,String fileExt){
                  java.net.URL urlfile 
          = null;
                  HttpURLConnection httpUrl 
          = null;

                  
          try {

                      
          // 連接指定的網(wǎng)絡(luò)資源,獲取網(wǎng)絡(luò)輸入流
                      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);
                      }

                  }


              }
                大家看代碼,第一個(gè)方法是讀取遠(yuǎn)程的文件,生成同樣的目錄文件,下面的方法是生成文件夾

          posted on 2007-06-25 13:39 imcb 閱讀(630) 評(píng)論(1)  編輯  收藏

          評(píng)論

          # re: 讀取遠(yuǎn)程文件,然后在指定目錄下生成同樣的文件 2007-09-27 19:18 yukingyee

          參數(shù)還是應(yīng)該說(shuō)明一下  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 乌拉特前旗| 新疆| 黑河市| 潼关县| 邵武市| 阿克陶县| 商南县| 虎林市| 阿拉善右旗| 海宁市| 卓资县| 阿克陶县| 尼木县| 郓城县| 安国市| 忻城县| 朔州市| 镇远县| 法库县| 布拖县| 天气| 英山县| 平利县| 阿尔山市| 平远县| 青铜峡市| 桐乡市| 佛冈县| 那曲县| 陇西县| 调兵山市| 海盐县| 当涂县| 柘城县| 绥阳县| 宣恩县| 滨州市| 海林市| 福州市| 永登县| 上思县|