第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Java從服務(wù)器端下載文件保存到本地,不是下載的圖片?

Java從服務(wù)器端下載文件保存到本地,不是下載的圖片?

一只斗牛犬 2019-03-22 18:15:58
public static void downloadFile(String urlPath, String filePath) throws IOException {        URL url = new URL(urlPath);        String name = urlPath.substring(urlPath.lastIndexOf("=")+1);        String filePaths = filePath+"/"+name;        File dirFile = new File(filePath);        if (!dirFile.exists()) {            dirFile.mkdir();        }        URLConnection connection = url.openConnection();        InputStream in = connection.getInputStream();        FileOutputStream os = new FileOutputStream(filePaths);        byte[] buffer = new byte[4 * 1024];        int read;        while ((read = in.read(buffer)) > 0) {            os.write(buffer, 0, read);        }        os.close();        in.close();    }    public static void main(String[] args) {        String urlPath = "http://10.192.32.111:80/production-jcw/getDownload.do?fileName=49e23d3a-5e11-432d-9f33-91c93130b37b.dwg";        String filePath = "C:/Users/MrLi/Desktop/";        try {            downloadFile(urlPath, filePath);            System.out.println("下載成功");        } catch (IOException e) {            e.printStackTrace();            System.out.println("下載失敗");        }    }
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 453 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)