java页面代码下载_java 下载页面代码

String fileName="";

String filePath = "d://max//";//下载文件目录,可以在配置文件中读取

if (request.getParameter("file") != null) {

fileName = request.getParameter("file");

}

response.reset();

response.setHeader("Content-disposition","attachment; filename="+fileName);

// response.setContentType("application/ms-excel");

BufferedInputStream   bis = null;

BufferedOutputStream   bos = null;

try {

System.out.println("Ready to transform file:"+filePath+fileName);

bis = new BufferedInputStream(new FileInputStream(filePath + fileName));

bos = new BufferedOutputStream(response.getOutputStream());

byte[] buff = new byte[2048];

int bytesRead;

while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {

bos.write(buff,0,bytesRead);

System.out.println("Each time read content :"+buff.toString());

}

System.out.println("End of transform the file :"+fileName);

} catch(final IOException e) {

System.out.println ( "IOException." + e );

} finally {         if (bis != null)             bis.close();         if (bos != null)             bos.close();     }%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为你提供一些 Java-Android 页面跳转和结构搭建的基础知识。 在 Android 中,页面的跳转是通过 Intent 实现的。Intent 是 Android 中用于组件之间通信的一种机制,它可以启动一个新的 Activity,也可以用于启动其他应用程序的组件。 下面是一个简单的页面跳转示例代码: ``` Intent intent = new Intent(MainActivity.this, SecondActivity.class); startActivity(intent); ``` 其中,MainActivity.this 是当前 Activity 的上下文,SecondActivity.class 是要跳转的目标 Activity。 在 Android 中,页面通常是由多个 View 组成的,因此在构建页面结构时,需要使用 ViewGroup 来组织 View 的布局。常用的 ViewGroup 包括 LinearLayout、RelativeLayout、FrameLayout 等。 下面是一个简单的页面布局示例代码: ``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click Me" android:onClick="onClick" /> </LinearLayout> ``` 其中,LinearLayout 是一个垂直方向的布局容器,TextView 和 Button 分别是布局容器中的两个 View。 这只是一个简单的示例,实际上 Android 中的页面结构和布局可以非常复杂,需要根据具体的需求进行设计和实现。 希望这些信息能对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值