日期:2014-05-18  浏览次数:20689 次

关于InputStream问题
用url与绝对路径获得InputStream哪个快
例如下面两个方法哪个快,两个都是指向同一个文件
URL   url   =   new   URL( "http://192.168.10.111:8080/test/files/test.txt ");
URLConnection   connection   =   url.openConnection();
HttpURLConnection   httpConn   =   (HttpURLConnection)   connection;
InputStream   fs   =httpConn.getInputStream();

InputStream   fs   new   FileInputStream( "F:/project/test/files/test.txt ");


------解决方案--------------------
第一个问题:当然是直接从本地磁盘取得文件快.
第二个问题:使用二进制流读取,例如ByteArrayInputStream
------解决方案--------------------
1 先new个ImageIcon 或者Image对象 然后得到高度宽度
2 或者RandomAccessFile 读取bmp 根据格式 得到高度宽度

bmp格式很简单的
------解决方案--------------------
看看这个: http://schmidt.devlib.org/java/image-faq/index.html