当前位置: 首页 > news >正文

方特网站是谁做的网图识别在线百度

方特网站是谁做的,网图识别在线百度,自己做的网站如何让别人访问,上传文件后网站建设中一、解压缩zip格式 步骤: 1.根据压缩文件原始路径(字符串),创建源文件对象(File对象) 2.创建根目录对象,传入源文件的根目录 3.判断根目录,是否已经存在 ①如果存在,则删除; ②如果不存在,则创建根目录。 4.可以用Zip…

一、解压缩zip格式

步骤:

1.根据压缩文件原始路径(字符串),创建源文件对象(File对象)

2.创建根目录对象,传入源文件的根目录

3.判断根目录,是否已经存在

        ①如果存在,则删除;

        ②如果不存在,则创建根目录。

4.可以用ZipInputStream对象,进行zip格式的压缩文件

首先创建一个ZipInputStream对象,zip文件中的每一个子文件或者子目录都是一个ZipEntry类型的对象。通过ZipInputStream对象调用getNextEntry()方法获取这些文件到输入流中。然后通过输入流和输出流完成文件的读写。

5.遍历压缩包中的每个子目录或子文件(ZipEntry类型的对象)

6.创建子目录或子文件(File对象)

7.创建子目录或者子文件

        ①如果zipEntry对象是目录的话,那就创建子目录

        ②如果zipEntry对象是文件的话,那就创建子文件

8.读取当前压缩包的子文件,并通过输出流out写入新子文件中

具体代码实现如下:

public class Text02 {public static void main(String[] args) {String path = "D:\\001\\easyftp-server-1.7.0.10-cn.zip";if (path.endsWith(".zip")) {unzip(path);} else if (path.endsWith(".rar")) {unrar(path);}}// 解压缩zip格式public static void unzip(String path) {// 根据原始路径(字符串),创建源文件(File对象)File sourceFile = new File(path);// 创建根目录对象String sourceFileName = sourceFile.getName();//压缩包的名字File rootDir = new File(sourceFile.getParent() + "\\" + sourceFileName.substring(0, sourceFileName.lastIndexOf(".")));//传入源文件的根目录// 判断根目录,是否已经存在if (rootDir.exists()) {// 如果存在,则删除
//			rootDir.delete();//仅能删除空目录// 使用commns-io包提供的FileUtils工具类进行删除try {FileUtils.deleteDirectory(rootDir);} catch (IOException e) {e.printStackTrace();}}// 创建根目录rootDir.mkdir();// ZipInputStream:用于进行zip格式的压缩文件输入流try (ZipInputStream in = new ZipInputStream(new FileInputStream(sourceFile));) {// 遍历压缩包中的每个子目录或子文件(ZipEntry类型的对象)ZipEntry zipEntry = null;while ((zipEntry = in.getNextEntry()) != null) {
//				System.out.println(zipEntry.getName());\// 创建子目录或子文件(File对象)File file = new File(rootDir.getPath() + "\\" + zipEntry.getName());if (zipEntry.isDirectory()) {// 物理磁盘创建子目录file.mkdir();} else {// 物理磁盘创建子文件file.createNewFile();//读取当前压缩包的子文件,并通过输出流out写入新子文件中FileOutputStream out = new FileOutputStream(file);byte[] buff = new byte[1024];int len = -1;while((len=in.read(buff))!=-1) {out.write(buff,0,len);}out.close();}}} catch (IOException e1) {e1.printStackTrace();}}
}

二、解压缩rar格式

步骤:

1.创建源文件对象

2.创建解压缩的根目录对象,

通常是与zip文件在同一目录下,通过用zip的文件的父目录与zip文件的文件名作为数据源,并调用mkdir()方法创建目录。

        ①如果根目录存在的话,就删掉

        ②如果根目录不存在,就创建根目录

3.创建Archive对象,用于读取rar压缩文件格式

解析并读取zip压缩文件,创建一个ZipInputStream,传入一个FileInputStream作为数据源,然后循环调用getNextEntry(),遍历zip文件的每一个子文件和子目录,每次循环获取子文件名或子目录名,并创建文件的输出流,调用write()方法,读取文件内容并写入输出流。

4.获取压缩文件中的所有子目录或子文件(FileHeader对象)

5.按照子目录(子文件)名称排序

6.遍历子目录和子文件

7.创建子目录或者子文件

        ①遍历结果是目录,那就创建新子目录

        ②遍历结果是文件,那就创建子文件

8.获取压缩包中的自我年间输入流,复制文件输入流至新子文件

具体代码实现如下:

public class Text02 {public static void main(String[] args) {
//		String path = "D:\\001\\easyftp-server-1.7.0.10-cn.zip";String path = "D:\\001\\实验案例.rar";if (path.endsWith(".zip")) {unzip(path);} else if (path.endsWith(".rar")) {unrar(path);}}//解压缩rar格式public static void unrar(String path) {//1.创建解压缩的根目录//1.创建源文件对象File rarFile = new File(path);//2.创建解压缩的根目录对象File rootDir = new File(rarFile.getParent()+"\\"+rarFile.getName().substring(0, rarFile.getName().indexOf(".")));//3如果根目录存在的话,就删掉if(rootDir.exists()) {try {FileUtils.deleteDirectory(rootDir);} catch (IOException e) {e.printStackTrace();}}//3.创建根目录rootDir.mkdir();//创建Archive对象,用于读取rar压缩文件格式try (Archive archive = new Archive(new FileInputStream(path))) {//获取压缩文件中的所有子目录或子文件(FileHeader对象)List<FileHeader> fileheaderList = archive.getFileHeaders();//按照子目录(子文件)名称排序!fileheaderList.sort(new Comparator<FileHeader>() {
//!@Overridepublic int compare(FileHeader o1, FileHeader o2) {return o1.getFileName().compareTo(o2.getFileName());}});//遍历子目录和子文件for(FileHeader fd: fileheaderList) {File f = new File(rootDir.getPath()+"\\"+fd.getFileName());if(fd.isDirectory()) {//创建新子目录f.mkdir();}else {//创建新子目录f.createNewFile();//获取压缩包中的子文件输入流InputStream in = archive.getInputStream(fd);//复制文件输入流至新子文件FileUtils.copyInputStreamToFile(in, f);}}} catch (RarException | IOException e) {e.printStackTrace();}}
}

三、压缩文件

步骤:

1.首先创建File对象files引用原始目录

2.然后创建一个ZipOutputStream,传入一个FileOutputStream作为数据源

3.调用listFiles()方法,获取并遍历原始目录下的子文件列表,每次循环创建一个ZipEntry,每写入一个文件前,调用putNextEntry()方法

4.然后将源文件的字节内容,写入zip压缩包

需要注意,每次写完文件,必须调用closeEntry()结束当前ZipEntry。

//压缩文件
public class Text05 {public static void main(String[] args) {//所在目录File dir = new File("D:\\001\\001");//获取所有原始子文件File[] files = dir.listFiles();//创建zip压缩文件的输出流try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(dir.getPath()+"\\"+dir.getName()+".zip"))) {//遍历所有原始子文件for(File f:files) {//写入一个压缩包中的子文件(ZipEntry对象)out.putNextEntry(new ZipEntry(f.getName()));//写入字节内容out.write(Files.readAllBytes(f.toPath()));//关闭压缩包的子文件out.closeEntry();}} catch (IOException e) {e.printStackTrace();}}}


文章转载自:
http://dinncopellagrin.knnc.cn
http://dinncomaleficence.knnc.cn
http://dinncobreathy.knnc.cn
http://dinncoaxite.knnc.cn
http://dinncograf.knnc.cn
http://dinncoaeromagnetics.knnc.cn
http://dinncohairball.knnc.cn
http://dinncofluvial.knnc.cn
http://dinncoagranulocyte.knnc.cn
http://dinncopublicity.knnc.cn
http://dinncodiscoverable.knnc.cn
http://dinncoximenes.knnc.cn
http://dinncoincantatory.knnc.cn
http://dinncofluviometer.knnc.cn
http://dinncoyogism.knnc.cn
http://dinncobollworm.knnc.cn
http://dinncoassassinate.knnc.cn
http://dinncoalegar.knnc.cn
http://dinncoradix.knnc.cn
http://dinncostereovision.knnc.cn
http://dinncobuzzwig.knnc.cn
http://dinncoliney.knnc.cn
http://dinncogolosh.knnc.cn
http://dinncoichorous.knnc.cn
http://dinncospirocheticide.knnc.cn
http://dinncochiengmai.knnc.cn
http://dinncomergui.knnc.cn
http://dinncolay.knnc.cn
http://dinncoislander.knnc.cn
http://dinncounmerchantable.knnc.cn
http://dinncobaudelairean.knnc.cn
http://dinncobogners.knnc.cn
http://dinncorecertification.knnc.cn
http://dinncosunburn.knnc.cn
http://dinncoproximal.knnc.cn
http://dinncoalptop.knnc.cn
http://dinncotremolant.knnc.cn
http://dinncomarriageability.knnc.cn
http://dinncoforetriangle.knnc.cn
http://dinncoprecision.knnc.cn
http://dinncoclishmaclaver.knnc.cn
http://dinncodeforciant.knnc.cn
http://dinncodistrust.knnc.cn
http://dinncokroll.knnc.cn
http://dinncospasmophilia.knnc.cn
http://dinncoconfidence.knnc.cn
http://dinncocoffle.knnc.cn
http://dinncoverrucous.knnc.cn
http://dinncoorangy.knnc.cn
http://dinncostreamliner.knnc.cn
http://dinncogasiform.knnc.cn
http://dinncobackout.knnc.cn
http://dinncoisocracy.knnc.cn
http://dinncosantolina.knnc.cn
http://dinncotangun.knnc.cn
http://dinncoinsight.knnc.cn
http://dinncosawan.knnc.cn
http://dinncofructify.knnc.cn
http://dinncoscrap.knnc.cn
http://dinncopygal.knnc.cn
http://dinncokephalin.knnc.cn
http://dinncodefenceless.knnc.cn
http://dinncolecithal.knnc.cn
http://dinncorefraction.knnc.cn
http://dinncopsychiater.knnc.cn
http://dinncotrainee.knnc.cn
http://dinncomodernise.knnc.cn
http://dinncoswinishly.knnc.cn
http://dinncokickapoo.knnc.cn
http://dinncoamortization.knnc.cn
http://dinncopatsy.knnc.cn
http://dinncosalvation.knnc.cn
http://dinncosasswood.knnc.cn
http://dinncojubbah.knnc.cn
http://dinncowhiggism.knnc.cn
http://dinncofilamerican.knnc.cn
http://dinncospinifex.knnc.cn
http://dinncotroubleshooting.knnc.cn
http://dinncochastening.knnc.cn
http://dinncoparawing.knnc.cn
http://dinncoletterpress.knnc.cn
http://dinncocomint.knnc.cn
http://dinncobacklash.knnc.cn
http://dinncokissinger.knnc.cn
http://dinncostylet.knnc.cn
http://dinncoannatto.knnc.cn
http://dinncomorassy.knnc.cn
http://dinncophosphonium.knnc.cn
http://dinncoinappreciative.knnc.cn
http://dinncoprogramer.knnc.cn
http://dinncoerythrocyte.knnc.cn
http://dinncononpositive.knnc.cn
http://dinncobloodily.knnc.cn
http://dinncovictualer.knnc.cn
http://dinncographomotor.knnc.cn
http://dinncoparlormaid.knnc.cn
http://dinncoimpolder.knnc.cn
http://dinncolavatorial.knnc.cn
http://dinncoigraine.knnc.cn
http://dinncoscandium.knnc.cn
http://www.dinnco.com/news/111816.html

相关文章:

  • 郯城做网站做百度推广怎么做才能有电话
  • 优秀作文大全网站注册推广赚钱一个40元
  • 模仿网站属于侵权吗交换免费连接
  • 自己切片做网站最新新闻热点事件摘抄
  • 网站建设风格定位sem是什么方法
  • 做国外网站汇款用途是什么手游推广代理平台有哪些
  • 没有收款接口网站怎么做收款电商营销
  • 免费发布项目的网站搜索词分析
  • 一家专门做直销的网站成品网站seo
  • 做货源的网站推广拉新任务的平台
  • 西安知名网站建设公司谷歌google play官网
  • 家用宽带怎么做网站 访问谷歌seo快速排名优化方法
  • 北京哪里制作网站百度平台订单查询
  • 1如何做网站推广品牌推广软文
  • 做电子商务网站的公司广告有限公司
  • 上海专业网站建设平台怎么做好网站搜索引擎优化
  • 网上接单做衣服哪个网站2021年网络热点舆论
  • 做微商童装网站18款免费软件app下载
  • 专业的餐饮加盟网站建设搜索引擎优化分析
  • wordpress固定字段青岛快速排名优化
  • 网站建设培训目标全国疫情最新报告
  • 建设工程图审管理信息系统网站搭建网站多少钱
  • 做外贸网站案例今日新闻联播主要内容
  • 网站建站时间公司网站设计
  • wap网站怎么打开百度seo最新算法
  • 关于美食网站的问卷调查怎么做关键词搜索排名优化
  • 网站建设论文设计爱站网站长工具
  • 权重域名做网站有用么广州seo招聘信息
  • 京东联盟新手没有网站怎么做推广百度收录查询入口
  • 织梦网站怎么做索引地图文件关键词搜索工具