ITeye博客

java 读取和保存图片

shenghw · 2014-10-12 11:22 · java基础 · 编程语言 · Markdown

// 读取图片文件 InputStream in = new FileInputStream( "c:/test.png"); byte photo = new byte; in.read(photo); in.close();

	OutputStream out = new FileOutputStream("c:/copy.png");
	out.write(user.getPhoto());
	out.close();

使用到的实体User /**

  • 实体
  • @author tyg

*/ public class User { private int id; private String name; private Integer age; private Date birthday; // 生日 private String desc; // 一大段说明 private byte photo; // 头像图片

public int getId() {
	return id;
}

public void setId(int id) {
	this.id = id;
}

public String getName() {
	return name;
}

public void setName(String name) {
	this.name = name;
}

public int getAge() {
	return age;
}

public void setAge(int age) {
	this.age = age;
}

public Date getBirthday() {
	return birthday;
}

public void setBirthday(Date birthday) {
	this.birthday = birthday;
}

public String getDesc() {
	return desc;
}

public void setDesc(String desc) {
	this.desc = desc;
}

public byte getPhoto() {
	return photo;
}

public void setPhoto(byte photo) {
	this.photo = photo;
}

public void setAge(Integer age) {
	this.age = age;
}

@Override
public String toString() {
	return "";
}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。