Java中将html转化为字符转
来源:互联网 发布:let it go 英文歌词 编辑:程序博客网 时间:2024/05/22 08:26
一、将HMTL转化为字符串
public static void main(String[] args) {File fin = new File("E:\\templateOfMail\\新供应商商务合作申请.html");try (RandomAccessFile accessFile = new RandomAccessFile(fin, "r");FileChannel fcin = accessFile.getChannel();){Charset charset = Charset.forName("UTF-8");int bufSize = 100000; ByteBuffer rBuffer = ByteBuffer.allocate(bufSize); String enterStr = "\n";byte[] bs = new byte[bufSize];StringBuilder strline = new StringBuilder("");StringBuilder strBuf = new StringBuilder("");while (fcin.read(rBuffer) != -1) {int rSize = rBuffer.position();rBuffer.rewind();rBuffer.get(bs);rBuffer.clear();String tempString = new String(bs, 0, rSize,charset);tempString = tempString.replaceAll("\r", "");int fromIndex = 0;int endIndex = 0;while ((endIndex = tempString.indexOf(enterStr, fromIndex)) != -1) {String line = tempString.substring(fromIndex, endIndex);line = strBuf.toString() + line;strline.append(line.trim());strBuf.delete(0, strBuf.length());fromIndex = endIndex + 1;}if (rSize > tempString.length()) {strline.append(tempString.substring(fromIndex, tempString.length()));strBuf.append(tempString.substring(fromIndex, tempString.length()));} else {strline.append(tempString.substring(fromIndex, rSize));strBuf.append(tempString.substring(fromIndex, rSize));}}System.out.println(strline.toString().replaceAll("\"", "'"));} catch (Exception e) {}}
阅读全文
0 0
- Java中将html转化为字符转
- Java中将单个字符以及字符串转化为数字
- java中将byte转化为字母
- Java中将数组转化为List
- VC(MFC)中将整型转化为字符型
- JAVA中将十进制转化为二进制并打印出来
- java中将一个obj对象转化为json对象
- Java中将时间戳转化为Date类型
- java中将jsonObject字符串转化为Map对象
- eclipse中将java项目转化为web项目
- java代码中将金额阿拉伯数字转化为中文大写
- java中将jsonObject字符串转化为Map对象
- java中将String转化为date,并进行比较
- Java 中将 String 转化为 Date 和 DateTime
- java中将字符串或者数组转化为json格式
- 通过js把html标签转化为普通字符,再用java进行反转
- java读取图片转化为字符画
- java实现图片转化为字符图片
- 博客开张
- Java中的native使用
- 手写SpringMVC框架
- TEST
- requests库入门-8-POST方法举例
- Java中将html转化为字符转
- Plugin with id 'com.github.dcendents.android-maven' not found
- ==和equals的区别
- ubuntu中如何查看系统信息(uname)
- Calendar
- 欢迎使用CSDN-markdown编辑器
- ros hello world 实现
- 三大框架知识点之 spring注解
- 快速搭建一个开源的Git服务器