关于裁剪系统后启动mount: could not find filesystem '/dev/root'问题
2015-08-03 17:00
435 查看
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.File;
import javax.imageio.ImageIO;
public class Img2 {
//读取远程url图片,得到宽高
public int[] returnImgWH(String imgurl) {
boolean b=false;
try {
//实例化url
URL url = new URL(imgurl);
//载入图片到输入流
java.io.BufferedInputStream bis = new BufferedInputStream(url.openStream());
//实例化存储字节数组
byte[] bytes = new byte[100];
//设置写入路径以及图片名称
OutputStream bos = new FileOutputStream(new File( "C:\\thetempimg.gif"));
int len;
while ((len = bis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
bis.close();
bos.flush();
bos.close();
//关闭输出流
b=true;
} catch (Exception e) {
//如果图片未找到
b=false;
}
int[] a = new int[2];
if(b){ //图片存在
//得到文件
java.io.File file = new java.io.File("C:\\thetempimg.gif");
BufferedImage bi = null;
try {
//读取图片
bi = javax.imageio.ImageIO.read(file);
} catch (IOException ex) {
ex.printStackTrace();
}
a[0] = bi.getWidth(); //获得 宽度
a[1] = bi.getHeight(); //获得 高度
//删除文件
file.delete();
}else{ //图片不存在
a=null;
}
return a;
}
public static void main(String[] args) {
Img2 i = new Img2();
int[] a=i.returnImgWH("http://www.baidu.com/img/baidu_logo.gif");
if(a==null){
System.out.println("图片未找到!");
}else{
System.out.println("宽为" + a[0]);
System.out.println("高为" + a[1]);
}
}
}
import java.awt.image.BufferedImage;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.File;
import javax.imageio.ImageIO;
public class Img2 {
//读取远程url图片,得到宽高
public int[] returnImgWH(String imgurl) {
boolean b=false;
try {
//实例化url
URL url = new URL(imgurl);
//载入图片到输入流
java.io.BufferedInputStream bis = new BufferedInputStream(url.openStream());
//实例化存储字节数组
byte[] bytes = new byte[100];
//设置写入路径以及图片名称
OutputStream bos = new FileOutputStream(new File( "C:\\thetempimg.gif"));
int len;
while ((len = bis.read(bytes)) > 0) {
bos.write(bytes, 0, len);
}
bis.close();
bos.flush();
bos.close();
//关闭输出流
b=true;
} catch (Exception e) {
//如果图片未找到
b=false;
}
int[] a = new int[2];
if(b){ //图片存在
//得到文件
java.io.File file = new java.io.File("C:\\thetempimg.gif");
BufferedImage bi = null;
try {
//读取图片
bi = javax.imageio.ImageIO.read(file);
} catch (IOException ex) {
ex.printStackTrace();
}
a[0] = bi.getWidth(); //获得 宽度
a[1] = bi.getHeight(); //获得 高度
//删除文件
file.delete();
}else{ //图片不存在
a=null;
}
return a;
}
public static void main(String[] args) {
Img2 i = new Img2();
int[] a=i.returnImgWH("http://www.baidu.com/img/baidu_logo.gif");
if(a==null){
System.out.println("图片未找到!");
}else{
System.out.println("宽为" + a[0]);
System.out.println("高为" + a[1]);
}
}
}
相关文章推荐
- 微信支付
- 数据结构之栈和队列---队列的基本操作
- hdu 5312 Sequence
- linux上使用LD_DEBUG环境变量查看程序使用哪些库
- 千与千寻
- hdu 3974 Assign the task
- 47.关于gradle的解疑
- 总结CSS3新特性(Animation篇)
- hdu 3917 Road constructions 最大权闭合子图
- php构造函数连接数据库
- LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- Java学习笔记------如何为文本输入框设置下凹效果?
- 查看linux版本的命令
- hdu 2102 A计划 BFS
- 解决Nginx: [error] open() "/usr/local/Nginx/logs/Nginx.pid
- SpringMVC学习笔记
- Android之MVC模式
- 使用Xcode7非美刀购买开发者帐号,非越狱安装IOS ipa
- js调用oc方法 UIWebView 跳 到另一个UIWebView
- Asp.net 5学习