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

pdf做电子书下载网站logo制作步骤

pdf做电子书下载网站,logo制作步骤,会员管理系统怎么做,中国公共招聘网Java中文网 - Java利用io类库对各种文件的操作详解java中提供了io类库#xff0c;可以轻松的用java实现对文件的各种操作。下面就来说一下如何用java来实现这些操作。新建目录//String URL request.getRequestURI();String filePathC:\\测试\\;filePathfilePath.…Java中文网 - Java利用io类库对各种文件的操作详解java中提供了io类库可以轻松的用java实现对文件的各种操作。下面就来说一下如何用java来实现这些操作。新建目录//String URL request.getRequestURI();String filePathC:\\测试\\;filePathfilePath.toString();//中文转换java.io.File myFilePathnew java.io.File(filePath);if(!myFilePath.exists())myFilePath.mkdir();%新建文件String filePathc:/测试/newFile.txt;filePathfilePath.toString();File myFilePathnew File(filePath);if(!myFilePath.exists())myFilePath.createNewFile();FileWriter resultFilenew FileWriter(myFilePath);PrintWriter myFilenew PrintWriter(resultFile);String content 这是测试数据;String strContent content.toString();myFile.println(strContent);resultFile.close();%删除文件String filePathc://测试//newFile.txt;filePathfilePath.toString();java.io.File myDelFilenew java.io.File(filePath);if(myDelFile.exists()){myDelFile.delete();out.println(filePath删除成功);}else{out.println(filePath该文件不存在);}%文件拷贝int bytesum0;int byteread0;//file:读到流中InputStream inStreamnew FileInputStream(c://测试//newFile.txt);FileOutputStream fsnew FileOutputStream( c://测试//copyFile.txt);byte[] buffer new byte[1444];int length;while ((bytereadinStream.read(buffer))!-1){out.println(byteread);bytesumbyteread;out.println(bytesum);fs.write(buffer,0,byteread);}inStream.close();%整个文件夹拷贝String url2d:/java/;(new File(url2)).mkdirs();File[] file(new File(url1)).listFiles();for(int i0;iif(file.isFile()){file.toString();FileInputStream inputnew FileInputStream(file);FileOutputStream outputnew FileOutputStream(url2/(file.getName()).toString());byte[] bnew byte[1024*5];int len;while((leninput.read(b))!-1){output.write(b,0,len);}output.flush();output.close();input.close();}}%文件下载String fileName newFile.txt.toString();//读到流中InputStream inStreamnew FileInputStream(c://测试//newFile.txt);//设置输出的格式response.reset();response.setContentType(text/plain);response.addHeader(Content-Disposition,attachment; filename\ fileName \);//循环取出流中的数据byte[] b new byte[100];int len;ServletOutputStream outStream response.getOutputStream();while((leninStream.read(b)) 0)outStream.write(b,0,len);outStream.flush();outStream.close();inStream.close();%数据库字段中的文件下载String id request.getParameter(id);if(idnull){ throw new Exception (没有找到图片);}else{try{com.gzrealmap.lib.jdbc.JDBCUtil SqlBean com.gzrealmap.lib.jdbc.JDBCUtil.getInstance();SqlBean.connect();String sql select * from innernews where id 79;ResultSet rs SqlBean.queryforUpdate(sql);rs.next();//String fileNamedb rs.getString(imageName);String file rs.getString(acc);//String fileName new String(fileNamedb.getBytes(),iso-8859-1);String fileName a.jpg;response.setHeader(Content-Disposition, inline; filename\ fileName \);String filter fileName.substring(fileName.lastIndexOf(.));if(filter.equals(.txt)){response.setContentType(text/plain);}else if(filter.equals(.doc)||filter.equals(.dot)){response.setContentType(application/msword);}else{response.setContentType(image/jpeg;CHARSETgbk);}ServletOutputStream o response.getOutputStream();//o.write(file);out.println(file);//o.flush();//o.close();SqlBean.disconnect();}catch(Exception ex){out.println(ex.getMessage());}}%把网页保存成文件URL stdURL null;BufferedReader stdIn null;PrintWriter stdOut null;try {stdURL new URL(http://www.163.com);}catch (MalformedURLException e) {throw e;}try {//将字节流转变成为字符流stdIn new BufferedReader(new InputStreamReader(stdURL.openStream()));String theFileName c://测试//163.html;stdOut new PrintWriter(new BufferedWriter(new FileWriter(theFileName.toString())));}catch (IOException e) {}/***把URL指定的页面以流的形式读出写成指定的文件***/try {String strHtml ;while((strHtml stdIn.readLine())!null) {stdOut.println(strHtml);}}catch (IOException e) {throw e;}finally {try {if(stdIn ! null)stdIn.close();if(stdOut ! null)stdOut.close();}catch (Exception e) {System.out.println(e);}}%直接下载网上的文件int bytesum0;int byteread0;URL url new URL(byte[] buffer new byte[1444];while ((bytereadinStream.read(buffer))!-1){out.println(byteread);bytesumbyteread;//System.out.println(bytesum);fs.write(buffer,0,byteread);}%按行读文件FileReader myFileReadernew FileReader(c:/哈哈.txt);BufferedReader myBufferedReadernew BufferedReader(myFileReader);String myStringnull;String resultStringnew String();while((myStringmyBufferedReader.readLine())!null) {resultStringresultStringmyString;}out.println(resultString);myFileReader.close();%对word文档的处理(上传与下载)response.setHeader(Content-disposition,inline; filenametest1.doc); //线上浏览方式// response.setHeader(Content-disposition,attachment; filenametest1.doc);//下载方式//以上这行设定传送到前端浏览器时的档名为test1.doc//就是靠这一行让前端浏览器以为接收到一个word档%//然后输出动态内容就可以得到一个word文档了1,打开1)文件头上加xml文件里docapplication/msword2)可以用js,以下代码来自引用var wrdnew ActiveXObject(Word.Application)wrd.visibletruealert (您的wrd.Application.Caption安装路径为\nwrd.Application.Path\n版本号是 wrd.Application.version\n注册使用者是wrd.Application.UserName)wrd.Documents.Add()//wrd.Documents.Open(c:\\exam.doc)wrd.Selection.TypeText(This is some text.)wrd.Application.Activate()wrd.ActiveDocument.SaveAs(c:\\exam111.doc)wrdnull2下载String filename jsp.doc;String filepath C:\\;// 设置响应头和下载保存的文件名response.setContentType(APPLICATION/OCTET-STREAM);response.setHeader(Content-Disposition,attachment; filename\ filename \);// 打开指定文件的流信息java.io.FileInputStream fileInputStream new java.io.FileInputStream(filepath filename);//FileOutputStream out new FileOutputStream(filepath测试\\ filename);// 写出流信息int i;while ((ifileInputStream.read()) ! -1) {out.write(i);}fileInputStream.close();out.close();%本文出自java 中文网(http://www.javaweb.cc/) -Java利用io类库对各种文件的操作详解
http://www.huolong8.cn/news/147047/

相关文章:

  • 企业网站开发总结网站运营策略
  • 郑州网站推广外包深圳怎么注册公司
  • 网站建设和托管哪家好电商网站 支付
  • 视频播放类网站建设费用微信公众平台小程序登录
  • 网站seo置顶免费公司logo设计
  • 企查查在线查询入口南昌seo计费管理
  • 重庆网领网站建设公司千华网鞍山门户网站
  • 北京正规网站建设比较传扬互动网站建设公司
  • 天津本地网站网站改成自适应
  • 企业网站备案审核需要多长时间河北省城乡住房和建设厅网站
  • 怎么做淘客的网站做家政有什么网站做推广好
  • 360网站图标怎么做的昆明做网站费用
  • 域名跟网站的区别网站收录少的原因
  • 广州建站公司有哪些怎么做自己网站
  • 做产品网站建设企业网站 seo怎么做
  • 网站模版建设工具大学网页设计作业
  • 甘肃网站备案网络服务商在哪咨询
  • 网站建设需要精通什么知识汝阳建设局网站
  • jquery做网站浏览量徐州企业建站系统模板
  • 做样子的网站河源新闻最新消息
  • 做家务的男人们在哪个网站播出开发一个平台
  • 怎样提高网站打开速度慢做做同城网站好还是做垂直网站好
  • 哪个汽车网站好泸县城乡住房建设厅网站
  • 关于成立网站建设项目小组的通知黄岩网站制作
  • 网站项目团队介绍深圳企业电话黄页
  • 个人 备案 多个网站吗做任务赚佣金的平台
  • 怎么用esc服务器做网站手机网站打不开是什么原因造成的
  • 哪个网站做系统好江苏推广网站建设业务
  • 濮阳网站建设哪家好wordpress如何加视频
  • 网站找人做备案的价格注册建设通网站