社区
Java SE
帖子详情
some questions
bonmot
2003-08-22 03:28:26
1.how to get the compter IP address which the Java precedure is running
2.how to download a file in JSP
3.how to do zipfile in Java
...全文
41
11
打赏
收藏
some questions
1.how to get the compter IP address which the Java precedure is running 2.how to download a file in JSP 3.how to do zipfile in Java
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
bonmot
2003-08-22
打赏
举报
回复
这样吧,我先结了这一贴,另开一贴,希望继续指教
bonmot
2003-08-22
打赏
举报
回复
is there simple way to zip a dir and its recursive files
bonmot
2003-08-22
打赏
举报
回复
download is not that simple,I try:
response.setContentType("application/msexcel");
OutputStream os = response.getOutputStream();
response.setHeader("Content-disposition","attachment; filename=courseware.xls");
os.write(bytes);
os.close();
but can't effect
wizardho
2003-08-22
打赏
举报
回复
ZipFile(File file)
Opens a ZIP file for reading given the specified File object.
ZipFile(File file, int mode)
Opens a new ZipFile to read from the specified File object in the specified mode.
ZipFile(String name)
Opens a zip file for reading.
cricketlj
2003-08-22
打赏
举报
回复
2.download直接连接到你的文件就可以,把你的文件放在webapps的某个目录下面
3.
package com.bj.zk.util.comm;
import java.util.*;
import java.sql.*;
import org.apache.log4j.Logger;
import java.util.zip.*;
import java.io.* ;
//******************************************
/**
*字符串压缩和解压缩
*@author 常通多维CTDW
*@version 2003.07.12
*/
//******************************************
public class ZipAndUnzip{
static Logger logger = Logger.getLogger(ZipAndUnzip.class.getName());
/**
* 字符串压缩
*@param String 被压缩字符串
*@exception exception 例外错误
*/
public void stringZip(String strXml)throws Exception{
byte[] bt;
bt=strXml.getBytes();
//在此路径生成ZIP文件target.zip
FileOutputStream fs = new FileOutputStream("C:/target.zip");
ZipOutputStream zipStream = new ZipOutputStream(fs);
try{
//创建target.zip的tableData.mxl被压缩文件
ZipEntry entry = new ZipEntry("tableData.xml");
//写数据到tableData.mxl
zipStream.putNextEntry(entry);
for(int i=0;i<bt.length/1000;i++){
zipStream.write(bt,i*1000,1000);
}
zipStream.write(bt,(bt.length/1000)*1000,bt.length-(bt.length/1000)*1000);
}catch(Throwable t){logger.info(t.toString());}
zipStream.close();
fs.close();
}
/**
* 字符串解压缩
*@return String 解压缩后字符串
*@exception exception,Throwable 例外错误
*/
public String stringUnzip()throws Exception,Throwable{
String st="";
try{
//被解压缩文件C:/target.zip
ZipFile zf=new ZipFile("C:/target.zip");
Enumeration e=zf.entries();
ZipEntry ze=(ZipEntry)e.nextElement();
//文件大小
int size=0;
size=(int)ze.getSize();
zf.close();
FileInputStream fis=new FileInputStream("C:/target.zip");
ZipInputStream zis=new ZipInputStream(fis);
ZipEntry entry = null;
entry=zis.getNextEntry();
//解成byte[]
byte[] b=new byte[size];
int rb=0;
int chunk=0;
while ((size - rb) > 0) {
chunk=zis.read(b,rb,size - rb);
if (chunk==-1) {
break;
}
rb+=chunk;
}
st=new String(b);
zis.close();
fis.close();
}catch(Throwable t){
logger.info(t.toString());
throw t;
}
return st;
}
}
hayai
2003-08-22
打赏
举报
回复
看看java.util.zip package.
zcjl
2003-08-22
打赏
举报
回复
那就up
:)
neuyqy
2003-08-22
打赏
举报
回复
up!
bonmot
2003-08-22
打赏
举报
回复
thanks,I've got
java.net.InetAddress.getLocalHost().getHostAddress()
nomenn
2003-08-22
打赏
举报
回复
InetAddress 类可以获得IP地址
bonmot
2003-08-22
打赏
举报
回复
up 有分
ASP.NET
Questions
and Answers 1
Some
questions
and answers regarding ASP.NET
ASP.NET
Questions
and Answers 2
Some
questions
and answers regarding ASP.NET, part 2
flutter插件调用APP页面、使用原生aar,framework库
本套课程适用于有一定的iOS、Android、Flutter开发基础。学完本次课程,能够让大家对Flutter如何调用移动端原生页面有一个清晰的认识;在纯Flutter开发过程中遇到需要调用原生功能的时候,能够快速定制属于自己或者公司的私有插件- Plugin。课程一共氛围两部分:1、Flutter插件跟iOS的交互部分:包括调用iOS原生页面、如何使用iOS的framework二进制、bundle资源文件、依赖的cocoapods资源;2、Flutter插件跟安卓的交互部分:包括调用Android原生页面、如何接收原生页面的回调、如何使用aar文件、依赖的其他资源。最终能够帮助大家定制私有插件;提升工作技能。备注:课程中使用环境[✓] Flutter (Channel stable, 1.22.5, on macOS 11.0.1 20B29 darwin-arm, locale zh-Hans-CN) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses[✓] Xcode - develop for iOS and macOS (Xcode 12.2)[!] Android Studio (version 4.1)[✓] IntelliJ IDEA Community Edition (version 2020.3)[✓] Connected device (1 available)
Questions
:some
questions
you may meet, like Cartesian Product(笛卡尔积),Postfix Expression(后缀表达式),and all ……
Questions
some
questions
you may meet, like Cartesian Product(笛卡尔积),Postfix Expression(后缀表达式),and all ……
ASP.NET Interview
Questions
Some common
questions
asked during interview regarding ASP.NET.
Java SE
62,615
社区成员
307,307
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章