博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
上传文件
阅读量:4638 次
发布时间:2019-06-09

本文共 697 字,大约阅读时间需要 2 分钟。

String filePath = "c:/";

  String fileName = request.getParameter("title");
        InputStream inputStream =request.getInputStream();
        FileOutputStream outputStream = new FileOutputStream(new File(filePath+fileName+".png"));
       
  //int formlength = request.getContentLength();
  int formlength = Integer.parseInt(request.getParameter("file"));
  byte[] formcontent = new byte[formlength];
  int totalread = 0;
  int nowread = 0;
  while (totalread < formlength) {
   nowread = inputStream.read(formcontent, totalread, formlength);
   totalread += nowread;
  }

        outputStream.write(formcontent);

        outputStream.flush();
        outputStream.close();
        inputStream.close();

转载于:https://www.cnblogs.com/java20130725/archive/2012/06/21/3215731.html

你可能感兴趣的文章
织梦教程
查看>>
杭电多校 Harvest of Apples 莫队
查看>>
java 第11次作业:你能看懂就说明你理解了——this关键字
查看>>
C/C++心得-结构体
查看>>
函数名作为参数传递
查看>>
apt-get for ubuntu 工具简介
查看>>
数值计算算法-多项式插值算法的实现与分析
查看>>
day8-异常处理与网络编程
查看>>
Python基础-time and datetime
查看>>
Linux epoll 笔记(高并发事件处理机制)
查看>>
shell脚本练习01
查看>>
WPF图标拾取器
查看>>
通过取父级for循环的i来理解闭包,iife,匿名函数
查看>>
HDU 3374 String Problem
查看>>
数据集
查看>>
打印python包含汉字报SyntaxError: Non-ASCII character '\xe4' in file
查看>>
[Leetcode] unique paths ii 独特路径
查看>>
HDU 1217 Arbitrage (Floyd + SPFA判环)
查看>>
IntelliJ idea学习资源
查看>>
Django Rest Framework -解析器
查看>>