快捷导航

idea下载路径的选择问题

String localAdd = "D:\\picture";
File dir = new File(localAdd);
if (!dir.exists()) {
    dir.mkdirs();
}
try {
    File file = new File(localAdd + "/" + imageName);
    OutputStream os = new FileOutputStream(file);
    URL url = new URL(Url);
    InputStream is = url.openStream();
    byte[] buff = new byte[1024];
    while (true) {
        int readed = is.read(buff);
        if (readed == -1) {
            break;
        }
        byte[] temp = new byte[readed];
        System.arraycopy(buff, 0, temp, 0, readed);
        // 写入文件
        os.write(temp);
    }
    is.close();
    os.close();
} catch (Exception e) {
    e.printStackTrace();
}




这是部分下载的代码,功能可用就是下载的路径不知道怎么改成可选择的

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

jFileChoose应该可以
回复

使用道具 举报

可能感兴趣的问答

发新帖
TA的信息
  • 会员所属: 注册会员
  • 认证信息: 邮箱认证手机认证
  • 微信访问
  • 手机APP