读书人

java InputStream 读取汉语言内容的解

发布时间: 2012-09-27 11:11:17 作者: rapoo

java InputStream 读取中文内容的解决乱码

String suffix=file.substring(file.lastIndexOf('.')+1,file.length());if("zip".equals(suffix)){try {InputStream ins=new FileInputStream(new File(file)); //URLConnection .getInputStream();ZipInputStream zipInput = new ZipInputStream(ins);  ZipEntry zipEntry=null;while ((zipEntry = zipInput.getNextEntry()) != null) {  //好像一定要是六才行啊byte[] buf = new byte[6];  int len=-1;String xml="";while ((len=zipInput.read(buf))!=-1) {  xml+=new String(buf,0,len,"utf-8");}  System.out.println(xml+"\t"+xml.length());}} catch (FileNotFoundException e) {log.info("parse zip file FileNotFoundException:"+e.getMessage());} catch (IOException e) {log.info("parse zip file IOException:"+e.getMessage());}}return null;

?

?//本人不敢全部一样的哦

读书人网 >开源软件

热点推荐