与我一起遨游吧
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 阅读(627) 评论(1) 编辑 收藏
参数还是应该说明一下 回复 更多评论
Powered by: BlogJava Copyright © imcb