亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    java如何實(shí)現(xiàn)保存文件到本地

    java如何實(shí)現(xiàn)保存文件到本地

    具體實(shí)現(xiàn)過(guò)程請(qǐng)看如下實(shí)例:(推薦學(xué)習(xí):java視頻教程)

    private void savePic(InputStream inputStream, String fileName) {       OutputStream os = null;     try {       String path = "D:\testFile\";       // 2、保存到臨時(shí)文件       // 1K的數(shù)據(jù)緩沖       byte[] bs = new byte[1024];       // 讀取到的數(shù)據(jù)長(zhǎng)度       int len;       // 輸出的文件流保存到本地文件         File tempFile = new File(path);       if (!tempFile.exists()) {         tempFile.mkdirs();       }       os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);       // 開(kāi)始讀取       while ((len = inputStream.read(bs)) != -1) {         os.write(bs, 0, len);       }       } catch (IOException e) {       e.printStackTrace();     } catch (Exception e) {       e.printStackTrace();     } finally {       // 完畢,關(guān)閉所有鏈接       try {         os.close();         inputStream.close();       } catch (IOException e) {         e.printStackTrace();       }     }   }

    推薦教程:java入門教程

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)