解决方案 »
- guid的主键,hibernate运行sql语句查询后既然只能取得主键的第一位值?
- Struts2.1.6+spring2.5.6+hibernate3.3.1框架集报错:Context initialization failed
- 请教一下struts1。2文本框怎么获取值的
- 求助:如何从数据库中字段并写入XML文件中
- JAVA有没有System.Web.UI.WebControls类似的类
- 求jfreechart在jsp中的用法?
- 解决立马给分,spring的初级问题,郁闷两天了!!!
- 已经用mysql建立了数据库,如何用struts进行操作,最好有简单的原代码
- 在安装Sun的petStore1.3.2的时候出现了以下错误,请帮忙。
- 我装了JB9,也装了Weblogic7,为什么JB9中的Tools->Configure Servers里的Weblogic7那一栏是灰的呢???
- apache james向外网发送邮件时提示错误
- 怎样用java操作文件型数据库
* 内存映射
*
* @throws IOException
*/
public static void mapChannel() throws IOException {
long t1 = System.currentTimeMillis();
FileInputStream in = new FileInputStream("d:/1.txt");
long size = in.available();
RandomAccessFile out = new RandomAccessFile("d:/2.txt", "rw");
FileChannel inc = in.getChannel();
MappedByteBuffer bf = inc.map(FileChannel.MapMode.READ_ONLY, 0, size);
FileChannel outc = out.getChannel();
MappedByteBuffer outbf = outc.map(FileChannel.MapMode.READ_WRITE, 0, size);
outbf.put(bf);
inc.close();
outc.close();
in.close();
out.close();
long t2 = System.currentTimeMillis();
System.out.println(t2 - t1);
}
(完全的内存映射)读文件是最快的,比任何其它读取方式快40倍,但你要BufferedImage结果那只能读到内存了
不只是读取文件,还要解析图像。