Consider this XML file.
1 2 3 4 5 6 7 8 9 10 |
<data> <employee> <name>John</name> <title>Manager</title> </employee> <employee> <name>Sara</name> <title>Clerk</title> </employee> </data> |
不因成就而狂妄、不因失落而气馁、不因欲望而沉重、不因嫉妒而困扰
JAVA, JAVAEE, Eclipse, Netbean
Consider this XML file.
1 2 3 4 5 6 7 8 9 10 |
<data> <employee> <name>John</name> <title>Manager</title> </employee> <employee> <name>Sara</name> <title>Clerk</title> </employee> </data> |
给下拉框赋值
1 2 3 4 |
<select id="type" name="type" > <option value="0">请选择</option> <option th:each="post:${posts}" th:value="${post.key}" th:text="${post.value}"></option> </select> |
给A标签赋值 [crayon- […]
maven中的仓库分为两种,snapshot快照仓库和release发布仓库。snapshot快照仓库用于保存 […]
密码学中的高级加密标准(Advanced Encryption Standard,AES),又称高级加密标准R […]
首先是文件类型枚取
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
package org.filetype; /** * 文件类型枚取 */ public enum FileType { /** * JEPG. */ JPEG("FFD8FF"), /** * PNG. */ PNG("89504E47"), /** * GIF. */ GIF("47494638"), /** * TIFF. */ TIFF("49492A00"), /** * Windows Bitmap. */ BMP("424D"), /** * CAD. */ DWG("41433130"), /** * Adobe Photoshop. */ PSD("38425053"), /** * Rich Text Format. */ RTF("7B5C727466"), /** * XML. */ XML("3C3F786D6C"), /** * HTML. */ HTML("68746D6C3E"), /** * Email [thorough only]. */ EML("44656C69766572792D646174653A"), /** * Outlook Express. */ DBX("CFAD12FEC5FD746F"), /** * Outlook (pst). */ PST("2142444E"), /** * MS Word/Excel. */ XLS_DOC("D0CF11E0"), /** * MS Access. */ MDB("5374616E64617264204A"), /** * WordPerfect. */ WPD("FF575043"), /** * Postscript. */ EPS("252150532D41646F6265"), /** * Adobe Acrobat. */ PDF("255044462D312E"), /** * Quicken. */ QDF("AC9EBD8F"), /** * Windows Password. */ PWL("E3828596"), /** * ZIP Archive. */ ZIP("504B0304"), /** * RAR Archive. */ RAR("52617221"), /** * Wave. */ WAV("57415645"), /** * AVI. */ AVI("41564920"), /** * Real Audio. */ RAM("2E7261FD"), /** * Real Media. */ RM("2E524D46"), /** * MPEG (mpg). */ MPG("000001BA"), /** * Quicktime. */ MOV("6D6F6F76"), /** * Windows Media. */ ASF("3026B2758E66CF11"), /** * MIDI. */ MID("4D546864"); private String value = ""; /** * Constructor. * * @param type */ private FileType(String value) { this.value = value; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } |
然后是类型判断核心类 [ […]
首先检查maven deploy plugin版本,有部分属性是高版本才能用,可以查看文档:http://ma […]
使用spring-mvc框架时,jetty找不到spring.tld和spring-form.tld 只能把s […]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileChannel.MapMode; public class FileUtils { /** * the traditional io way * @param filename * @return * @throws IOException */ public static byte[] toByteArray(String filename) throws IOException{ File f = new File(filename); if(!f.exists()){ throw new FileNotFoundException(filename); } ByteArrayOutputStream bos = new ByteArrayOutputStream((int)f.length()); BufferedInputStream in = null; try{ in = new BufferedInputStream(new FileInputStream(f)); int buf_size = 1024; byte[] buffer = new byte[buf_size]; int len = 0; while(-1 != (len = in.read(buffer,0,buf_size))){ bos.write(buffer,0,len); } return bos.toByteArray(); }catch (IOException e) { e.printStackTrace(); throw e; }finally{ try{ in.close(); }catch (IOException e) { e.printStackTrace(); } bos.close(); } } /** * NIO way * @param filename * @return * @throws IOException */ public static byte[] toByteArray2(String filename)throws IOException{ File f = new File(filename); if(!f.exists()){ throw new FileNotFoundException(filename); } FileChannel channel = null; FileInputStream fs = null; try{ fs = new FileInputStream(f); channel = fs.getChannel(); ByteBuffer byteBuffer = ByteBuffer.allocate((int)channel.size()); while((channel.read(byteBuffer)) > 0){ // do nothing // System.out.println("reading"); } return byteBuffer.array(); }catch (IOException e) { e.printStackTrace(); throw e; }finally{ try{ channel.close(); }catch (IOException e) { e.printStackTrace(); } try{ fs.close(); }catch (IOException e) { e.printStackTrace(); } } } /** * Mapped File way * MappedByteBuffer 可以在处理大文件时,提升性能 * @param filename * @return * @throws IOException */ public static byte[] toByteArray3(String filename)throws IOException{ FileChannel fc = null; try{ fc = new RandomAccessFile(filename,"r").getChannel(); MappedByteBuffer byteBuffer = fc.map(MapMode.READ_ONLY, 0, fc.size()).load(); System.out.println(byteBuffer.isLoaded()); byte[] result = new byte[(int)fc.size()]; if (byteBuffer.remaining() > 0) { // System.out.println("remain"); byteBuffer.get(result, 0, byteBuffer.remaining()); } return result; }catch (IOException e) { e.printStackTrace(); throw e; }finally{ try{ fc.close(); }catch (IOException e) { e.printStackTrace(); } } } } |
各发行包的大致描述如下: org.springframework.asm-3.0.0.M4.jar: 提供对A […]
Android和iOS那个好?应该先往哪个上面投入资源?多次被人问到此类问题,笔者刚好自己的项目也需要考虑iO […]
Win 2000 Temp、Tmp 的配置 因为我们生成的 ejb 相关代码要进行一系列的编译,那么所生成的临 […]
1:) 字符串转换成时间
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SimpleDateFormat formatter = new SimpleDateFormat ('yyyy.MM.dd'); //假定像2002.07.04的是合法日期其他都非法。 String str='2002.07.04'; ParsePosition pos = new ParsePosition(0); Date dt=formatter.parse(str,pos); if(dt!=null) { //是合法日期 } else { //非法日期 } |
2:)两个日期相减 […]
针对applet和awt: 1:) Font f = new Font(UIResource.getStrin […]
首先说一下hsqldb几个优点 轻巧,只有600多K,运行速度非常快。结合Hibernate数据库无关的特性, […]
?? Poi主要用来解决excel.word,powerpoint的读写问题,官方网站是http://jaka […]
SAXReader reader = new SAXReader();??? Document doc = r […]
??? 需要做一个垂直搜索引擎,比较了nekohtml和htmlparser 的功能,尽管nekohtml在容 […]
近日在调测一个UTF8编码的中文Zen Cart网站时遇到一件怪事,网页显示文字正常,用ie的察看源文件(记事 […]
Log4j Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地 […]
因为项目包含JAVA源文件和JSP源文件,要注意转换顺序 先用批量编码转换,转换为UTF-8(With BOM […]
1、Spring 2.5后将mvc模块独立出来了,所以要单独加上: spring-web.jar; sprin […]
在spring的web项目中常常会在tomcat启动的时候出现这种提示: log4j:WARN No appe […]
在eclipse GANYMEDE中apache-tomcat-6.0.16加载工程后,启动服务器就会出现如下 […]
关于JSP页面中的pageEncoding和contentType两种属性的区别: pageEncoding是 […]
开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。