具体实现过程请看如下实例:(推荐学习:java视频教程)
private void savepic(inputstream inputstream, string filename) {     outputstream os = null;    try {      string path = "d:\\testfile\\";      // 2、保存到临时文件      // 1k的数据缓冲      byte[] bs = new byte[1024];      // 读取到的数据长度      int len;      // 输出的文件流保存到本地文件       file tempfile = new file(path);      if (!tempfile.exists()) {        tempfile.mkdirs();      }      os = new fileoutputstream(tempfile.getpath() + file.separator + filename);      // 开始读取      while ((len = inputstream.read(bs)) != -1) {        os.write(bs, 0, len);      }     } catch (ioexception e) {      e.printstacktrace();    } catch (exception e) {      e.printstacktrace();    } finally {      // 完毕,关闭所有链接      try {        os.close();        inputstream.close();      } catch (ioexception e) {        e.printstacktrace();      }    }  }
推荐教程:java入门教程
以上就是java如何实现保存文件到本地的详细内容。
   
 
   