手机版办公软件开发总结.doc_第1页
手机版办公软件开发总结.doc_第2页
手机版办公软件开发总结.doc_第3页
手机版办公软件开发总结.doc_第4页
手机版办公软件开发总结.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

首先,在刚刚去的时候,对于手机这一块,我的大脑还是一片空白,从刚开始接触,我们就开始学习wml1.2的标签,开始一步一步的研究学习这些标签都有什么功能,完了,再经过不断的实践来验证这些功能,虽然这一部比较痛苦吧,自己还是坚持了下来,用了大概两周的时间,基本上算是把他搞懂了。让后再结合jsp实现动态编程。在这个项目中,框架是项目经理给我们搭好的,我们只是往里面添加东西,这点倒是没什么难的,手机毕竟是与电脑不同的,手机有他的限制性:屏幕小,还有最重要的的一点就是,带宽特别有限,所以显示图片,就必须得经过进一步的转化才能显示在手机上,在此用到了类import com.sun.image.codec.jpeg.JPEGCodec;import com.sun.image.codec.jpeg.JPEGImageEncoder;具体代码实现如下public class ImgTypeConv private static final Log log = LogFactory.getLog(ImgTypeConv.class);public static final String IMG_FORMAT_DEFAULT = GIF;public static final String IMG_FORMAT_GIF = GIF;public static final String IMG_FORMAT_JPG = JPG;public static final String IMG_FORMAT_PNG = PNG;public static final String IMG_FORMAT_BMP = BMP;private int iWidth = 50;private int iHeight = 100;private boolean bAutoResize = false;/private String sImgFormat = ImgTypeConv.IMG_FORMAT_DEFAULT; /* * 转换类析构函数,用于初始化图片转换所需要相当函数。 */public ImgTypeConv(int iWidth,int iHeight,boolean bAutoResize,String sImgFormat)this.iWidth = iWidth;this.iHeight = iHeight;this.bAutoResize = bAutoResize;/this.sImgFormat = sImgFormat;/* * 转换图片文件格式后另存为指定的目录 * param sUrl 源图片文件名称 如:/axx.jpg * param sDir 图片文件转换后存储路径 如:c:abcaxx.jpg * return 成功返回true,失败返回false * throws Exception */public boolean ConvFileToDir(String sUrl,String sDir) throws Exceptionboolean rtn = true;try URL url = new URL(sUrl);URLConnection conn = url.openConnection();Image image = ImageIO.read(conn.getInputStream();int _iWidth=0,_iHeight=0;if(this.bAutoResize) double rate1 = (double) image.getWidth(null) / (double) iWidth; double rate2 = (double) image.getHeight(null) / (double) iHeight; double rate = rate1 rate2 ? rate1 : rate2; _iWidth = (int) (double) image.getWidth(null) / rate); _iHeight = (int) (double) image.getHeight(null) / rate); else_iWidth = iWidth;_iHeight = iHeight;BufferedImage tag = new BufferedImage(_iWidth, _iHeight , BufferedImage.TYPE_INT_RGB);tag.getGraphics().drawImage(image.getScaledInstance(_iWidth, _iHeight , Image.SCALE_SMOOTH), 0, 0, null);FileOutputStream out = new FileOutputStream(sDir);JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);encoder.encode(tag);out.close(); catch (Exception e) log.error(图片转换出错:+e.getMessage();throw new Exception(图片转换出错:+e.getMessage();return rtn;/* * param args * throws Exception */public static void main(String args) throws Exception /URL url = new URL(/zjjy_images/zjjy_map.gif);ImgTypeConv imgTypeConv = new ImgTypeConv(80, 160, true, ImgTypeConv.IMG_FORMAT_DEFAULT);imgTypeConv.ConvFileToDir(/zjjy_images/zjjy_map.gif, c:ss.gif);再有一个问题就是由于数据库中的好多信息都是html格式的文件和Word中的文档,而在手机上并不识别这些信息,因此必须经过进一步的转化才能显示,在解析html时就用到了正则表达式/* * 将HTML格式的字符串转换成Text格式 * param inputString Html格式字符串 * return */public static String Html2TextTitle(String inputString) String strArr = !DOCTYPE,Font,P,html,head,body,meta,OBJECT,a,st1,b;Pattern p_style;Matcher m_style;for(int i=0;istrArr.length;i+)String regEx_html = *?; /定义HTML标签的正则表达式p_style = Ppile(regEx_html,Pattern.CASE_INSENSITIVE);m_style = p_style.matcher(inputString);inputString = m_style.replaceAll(); /过滤html标签p_style = Ppile(,Pattern.CASE_INSENSITIVE);m_style = p_style.matcher(inputString);inputString = m_style.replaceAll(>); /过滤style标签p_style = Ppile( ,Pattern.CASE_INSENSITIVE);m_style = p_style.matcher(inputString);inputString = m_style.replaceAll(); /过滤style标签return inputString;在读取Word文档时,用到了一个开源的技术POI,他可以读取Word文档。Oracle 中有两类比较特殊的数据BLOB、CLOB,就目前我所知道的他可以存储图片格式、html格式文本。从数据库中提取出来必须得经过转换,才能使用,转换如下:public static String getClog2Str(Object obj)String rtn=;if(obj != null)tryClob clob = (Clob)obj;Reader reader=clob.getCharacterStream();BufferedReader br=new BufferedReader(reader);String line=;while(line=br.readLine()!=null)rtn = rtn + line;catch(Exception e)log.error(CLOB类型转换成字符类型出错:+e.getMessage();return rtn;/* * 将Blob类型转换成字符串,具体功能请多多尝试。 * param obj Blob类型数据 * param filename * return * throws SQLException * throws IOException * author */public static String getBlob2Str(Object obj,String filename) throws SQLException, IOExceptionString rtn=;if(obj != null)tryBlob imgblob=(Blob)obj;BufferedInputStream bis = new BufferedInputStream(imgblob.getBinaryStream();long filesize=imgblob.length();int bufferSize =0;if(filesize 0)bufferSize = Integer.parseInt(String.valueOf(filesize);if(bufferSize = 0)log.error(文件大小太小(1)!);return null;String path=pt+filename;File folder = new File(pt);if (!folder.exists()folder.mkdir();/创建文件夹:filesFile f = new File(path);FileOutputStream out = new FileOutputStream(f); byte buffer = new bytebufferSize; int bytesRead =bis.read(buffer); if(bytesRead = 0)log.error(文件大小太小(2)!);return null;out.write(buffer); out.flush(); out.close(); bis.close(); rtn=TypeConv.getDoc2Str(path); catch(Exception e)lo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论