1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      java如何下載視頻到本地

      這篇文章主要介紹“java如何下載視頻到本地”,在日常操作中,相信很多人在java如何下載視頻到本地問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”java如何下載視頻到本地”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

      創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營銷推廣、網(wǎng)站重做改版、芝罘網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)商城網(wǎng)站開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為芝罘等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

      1.加載servlet容器

      不能使用main方法直接調(diào)用

        public static boolean httpDownload(String httpUrl, String saveFile) {
              // 1.下載網(wǎng)絡(luò)文件
              int byteRead;
              URL url;
              try {
                  url = new URL(httpUrl);
              } catch (MalformedURLException e1) {
                  e1.printStackTrace();
                  return false;
              }
       
              try {
                  //2.獲取鏈接
                  URLConnection conn = url.openConnection();
                  //3.輸入流
                  InputStream inStream = conn.getInputStream();
                  //3.寫入文件
                  FileOutputStream fs = new FileOutputStream(saveFile);
       
                  byte[] buffer = new byte[1024];
                  while ((byteRead = inStream.read(buffer)) != -1) {
                      fs.write(buffer, 0, byteRead);
                  }
                  inStream.close();
                  fs.close();
                  return true;
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
                  return false;
              } catch (IOException e) {
                  e.printStackTrace();
                  return false;
              }
          }
       
       
          @Test
          public void httpDownload() {
              httpDownload("http://video.zhihuishu.com/zhs/ablecommons/demo/201806/dddee1c446314b84a26c74a8def3c3c7.mp4","E:\\test/22.mp4");
          }

      2.添加common-io依賴

      import org.apache.commons.io.FileUtils;
       
      import java.io.File;
      import java.net.URL;
       
      public class TestDownloadFile {
       
          public static void main(String[] args) throws Exception{
              String urlStr = "https://img2018.cnblogs.com/i-beta/1278703/201911/1278703-20191128121650595-812419505.png";
              URL url = new URL(urlStr);
              String tempFileName = "E://a.png";
              File temp = new File(tempFileName);
              FileUtils.copyURLToFile(url, temp);
          }
      }

      到此,關(guān)于“java如何下載視頻到本地”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!


      當(dāng)前標(biāo)題:java如何下載視頻到本地
      文章源于:http://www.ef60e0e.cn/article/jjcpoi.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        华亭县| 麻江县| 西乌珠穆沁旗| 宜宾县| 壤塘县| 静海县| 华宁县| 洮南市| 永丰县| 库尔勒市| 苏尼特左旗| 临猗县| 巩留县| 郎溪县| 武宁县| 宁津县| 德昌县| 湖口县| 忻城县| 通化县| 尉氏县| 芦山县| 鹿泉市| 长宁区| 青川县| 株洲市| 始兴县| 桐乡市| 昔阳县| 共和县| 盈江县| 新野县| 木兰县| 开远市| 大同县| 开平市| 舞钢市| 开封市| 漾濞| 永修县| 广州市|