java servlet response:

bf.append("Shipment No, STT No, WIN Event, DateTime, WOU Envent, DateTime");
sbf.append('\n'); for(int i=0;i<list.size();i++)
{
PrintStatisticsForm psrform = list.get(i);
sbf.append(getCsvCommaString(psrform.getHawb()));
sbf.append(getCsvCommaString(psrform.getStt()));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWinevent())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWindatetime())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWouevent())));
sbf.append(getCsvCommaString(new HSSFRichTextString(psrform.getWoudatetime())));
sbf.append('\n');
}
sbf.append('\n');
sbf.append('\n');
sbf.append('\n');
	byte[] csvData = sbf.toString().getBytes();
response.setHeader("Content-Disposition", "attachment;filename=Shipment Inventory Report.csv");
response.setContentLength(sbf.length());
response.setContentType("application/csv");
response.setCharacterEncoding("UTF-8");
response.getOutputStream().write(csvData);
response.getOutputStream().flush();
response.getOutputStream().close();

C# response

foreach (var totalCell in totalCellList)
{
totalContent.AppendFormat("\t{0},", totalCell.Value);
}

totalContent.AppendFormat("\t{0},", cellCountList.Values.Sum());
totalContent.AppendFormat("\t{0},", priceEvianBooCountList.Values.Sum());//依云及波多金额总计
totalContent.AppendFormat("\t{0},", pricefuWekoCountList.Values.Sum());//富维克金额总计
totalContent.AppendFormat("\t{0},", priceCountList.Values.Sum());//订单金额总计
sbContent.Append(totalContent.ToString());
//---------------------汇总行end------------------------//

sb.Append(sbContent.ToString());

var fileName = string.Format("{0}{1:yyyyMMddHHmmss}", (exporttype == 0 ? "日常报表_" : "详细报表_"), DateTime.Now);
userLogService.LogSuccessOperation(string.Format("导出报表[{0}.csv]!", fileName));

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = false;
byte[] data = Encoding.Default.GetBytes(sb.ToString());
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".csv");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.BinaryWrite(data);
HttpContext.Current.Response.Flush();

//------------------------------------------

if (Request.Content.IsMimeMultipartContent())
{
var path = HttpContext.Current.Server.MapPath("~/App_Data");
var provider = new MultipartFormDataStreamProvider(path);
var task = Request.Content.ReadAsMultipartAsync(provider);
task.ContinueWith(t =>
{
if (t.IsFaulted || t.IsCanceled)
throw new HttpResponseException(HttpStatusCode.InternalServerError);
});
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}

java 和 C# 响应输出的相似度的更多相关文章

  1. JavaWeb学习笔记——开发动态WEB资源(一)Java程序向浏览器输出数据

    开发一个动态web资源,即开发一个Java程序向浏览器输出数据,需要完成以下2个步骤: 1.编写一个Java类,实现Servlet接口 开发一个动态web资源必须实现javax.servlet.Ser ...

  2. WebApi接口 - 响应输出xml和json

    格式化数据这东西,主要看需要的运用场景,今天和大家分享的是webapi格式化数据,这里面的例子主要是输出json和xml的格式数据,测试用例很接近实际常用情况:希望大家喜欢,也希望各位多多扫码支持和点 ...

  3. java数组元素的输出

    java数组元素的输出 利用Arrays.toString(数组名即可) String[] name = {"Tom", "John", "Nike& ...

  4. 用Delphi的TIdHttp控件发起POST请求和Java的Servlet响应

    http://blog.csdn.net/panjunbiao/article/details/8615880   用Delphi的TIdHttp控件发起POST请求和Java的Servlet响应

  5. Java 控制台输入数字 输出乘法表(代码练习)

    最近,回忆了一些刚学习Java时经常练习的一些小练习题.感觉还是蛮有趣的,在回顾时想起好多学习时的经历和坎坷,一道小小的练习题要研究半天,珍重过往,直面未来.下面贡献代码,Java 控制台输入数字 输 ...

  6. WebApi接口 - 响应输出xml和json 转

        格式化数据这东西,主要看需要的运用场景,今天和大家分享的是webapi格式化数据,这里面的例子主要是输出json和xml的格式数据,测试用例很接近实际常用情况:希望大家喜欢,也希望各位多多扫码 ...

  7. 网络爬虫技术实现java依赖库整理输出

    网络爬虫技术实现java依赖库整理输出 目录 1       简介... 2 1.1      背景介绍... 2 1.2      现有方法优缺点对比... 2 2       实现方法... 2 ...

  8. Java.控制层.响应工具类.

    Java.控制层.响应工具类. package cn.com.spdbccc.cds.index.web.base; public class ApiResponse { private int co ...

  9. java 如何正确的输出集合或者对象的值

    java 如何正确的输出集合或者对象的值 一般out.println(Object) 和 System.out.println(Object),其中输出的都是Object.toString()方法.重 ...

随机推荐

  1. vmware12中centos7以NAT连接网络

    1.第一步当然是安装VM和安装CentOS,我用的是VM12和64位的CentOS7,怎么安装在我的其他文中有写到: http://www.cnblogs.com/wuyx/p/7246675.htm ...

  2. 【KM】BZOJ1937 [Shoi2004]Mst 最小生成树

    这道题拖了好久因为懒,结果1A了,惊讶∑( 口 || [题目大意] 给定一张n个顶点m条边的有权无向图.现要修改各边边权,使得给出n-1条边是这张图的最小生成树,代价为变化量的绝对值.求最小代价之和. ...

  3. apose 根据excel 导出模版

    string file = Server.MapPath("~/Excel/ZWxxtj.xls");            DataSet ds = new DataSet(); ...

  4. python gensim的第一次试用

    参考于 http://blog.csdn.net/xiaoquantouer/article/details/53583980 有一个地方很重要,一定要安装anaconda,安装库简直不要太方便. 先 ...

  5. linux基础命令学习(三)文件搜索 find

    1.使用name选项 查找自己的根目录$Home中的文件,可以用: find ~ -name "*.log" -print  查找当前目录下的文件,可以用: find . -nam ...

  6. Testcase的编写

    ‘ID’用于记录某一功能: ‘标题’用于表示某一Case:(一个功能有多个Case) ‘优先级’标记Case的重要等级,运行顺序 ‘测试步骤’记录测试流程 1.Given:条件 2.And:进行某些前 ...

  7. mysql 虚拟列

    http://blog.csdn.net/yueliangdao0608/article/category/351407

  8. Effective C++:条款29:为“异常安全”而努力是值得的

    (一)先看以下这些代码: class PrettyMenu { public: void changeBackground(istream& imgSrc); private: Mutex m ...

  9. rt-80启动tomcat

    1 #!/bin/sh 2 cd /mnt/tomcat/tomcat_8082; 3 ps -ef|grep /tomcat_8082/ |awk '{print $2}'|xargs kill - ...

  10. QMsgPack简介

    QMsgPack简介 首先,关于MessagePack协议,访问http://msgpack.org可以了解详细的格式约定及各种语言的实现. MessagePack协议号称比JSON快,但速度的快慢这 ...