锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产性猛交xxxx免费看久久,日韩1区2区日韩1区2区,2020国产精品久久精品不卡http://www.aygfsteel.com/jiangwei/weizi2012zh-cnTue, 17 Jun 2025 04:55:11 GMTTue, 17 Jun 2025 04:55:11 GMT60java 鏂囦歡涓嬭澆http://www.aygfsteel.com/jiangwei/archive/2012/09/27/java.htmljiangweijiangweiThu, 27 Sep 2012 02:57:00 GMThttp://www.aygfsteel.com/jiangwei/archive/2012/09/27/java.htmlhttp://www.aygfsteel.com/jiangwei/comments/388668.htmlhttp://www.aygfsteel.com/jiangwei/archive/2012/09/27/java.html#Feedback2http://www.aygfsteel.com/jiangwei/comments/commentRss/388668.htmlhttp://www.aygfsteel.com/jiangwei/services/trackbacks/388668.html/**
  * 鏈湴涓嬭澆
  *
  * @param response
  * @throws FileNotFoundException
  */
 public void downloadLocal(HttpServletResponse response)
   throws FileNotFoundException {
  // 涓嬭澆鏈湴鏂囦歡
  String fileName = "Operator.doc".toString(); // 鏂囦歡鐨勯粯璁や繚瀛樺悕
  // 璇誨埌嫻佷腑
  InputStream inStream = new FileInputStream("c:/Operator.doc");// 鏂囦歡鐨勫瓨鏀捐礬寰?br />  // 璁劇疆杈撳嚭鐨勬牸寮?br />  response.reset();
  response.setContentType("bin");
  response.addHeader("Content-Disposition", "attachment; filename=\""
    + fileName + "\"");
  // 寰幆鍙栧嚭嫻佷腑鐨勬暟鎹?br />  byte[] b = new byte[100];
  int len;
  try {
   while ((len = inStream.read(b)) > 0)
    response.getOutputStream().write(b, 0, len);
   inStream.close();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }

 /**
  * 緗戠粶鏂囦歡涓嬭澆
  *
  * @param response
  * @throws MalformedURLException
  */
 public void downloadNet(HttpServletResponse response)
   throws MalformedURLException {
  // 涓嬭澆緗戠粶鏂囦歡
  int bytesum = 0;
  int byteread = 0;
  URL url = new URL("windine.blogdriver.com/logo.gif");
  try {
   URLConnection conn = url.openConnection();
   InputStream inStream = conn.getInputStream();
   FileOutputStream fs = new FileOutputStream("c:/abc.gif");
   byte[] buffer = new byte[1204];
   @SuppressWarnings("unused")
   int length;
   while ((byteread = inStream.read(buffer)) != -1) {
    bytesum += byteread;
    System.out.println(bytesum);
    fs.write(buffer, 0, byteread);
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }

 /**
  * 鏀寔鍦ㄧ嚎鎵撳紑涓嬭澆
  *
  * @param filePath
  * @param response
  * @param isOnLine
  * @throws Exception
  */
 public void downLoad(String filePath, HttpServletResponse response,
   boolean isOnLine,String fname) throws Exception {
  System.out.println("filePath:" + filePath);
  File f = new File(filePath);
  if (!f.exists()) {
   response.sendError(404, "File not found!");
   return;
  }
  BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
  byte[] buf = new byte[1024];
  int len = 0;
  response.reset(); // 闈炲父閲嶈
  if (isOnLine) { // 鍦ㄧ嚎鎵撳紑鏂瑰紡
   URL u = new URL("file:///" + filePath);
   response.setContentType(u.openConnection().getContentType());
   response.setHeader("Content-Disposition", "inline; filename="
     + fname);
   // 鏂囦歡鍚嶅簲璇ョ紪鐮佹垚UTF-8
  } else { // 綰笅杞芥柟寮?br />   response.setContentType("application/x-msdownload");
   response.setHeader("Content-Disposition", "attachment; filename="
     + fname);
  }
  OutputStream out = response.getOutputStream();
  while ((len = br.read(buf)) > 0)
   out.write(buf, 0, len);
  br.close();
  out.close();
 }



jiangwei 2012-09-27 10:57 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 石林| 嘉祥县| 安化县| 普格县| 昭苏县| 湖南省| 原阳县| 贡嘎县| 波密县| 泽州县| 尚义县| 静宁县| 沙田区| 那曲县| 绥江县| 甘德县| 长岭县| 理塘县| 隆回县| 普宁市| 安福县| 古浪县| 吉林市| 淄博市| 兴文县| 浦县| 武安市| 隆子县| 当涂县| 库伦旗| 武宣县| 六枝特区| 桂阳县| 博野县| 东莞市| 托里县| 称多县| 平利县| 井陉县| 钟祥市| 桂林市|