用流对图片进行剪切,粘贴
来源:互联网 发布:淘宝 微淘 ipad 编辑:程序博客网 时间:2024/04/30 23:07
package com.yc;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1 {
/*
*
* 实现对某一个图片的剪切和粘贴
*
*/
public static byte[] cut(File file)//剪切
{
BufferedInputStream bfd = null;
byte[]b =null;
try
{
bfd = new BufferedInputStream(new FileInputStream(file));
b = new byte[bfd.available()];
bfd.read(b);
}catch(FileNotFoundException e)
{
e.printStackTrace();
}catch(IOException e)
{
e.printStackTrace();
}
finally
{
try {
bfd.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return b;
}
public static void paste(byte[]b,File file)//粘贴
{
BufferedOutputStream bfw = null;
try
{
bfw = new BufferedOutputStream(new FileOutputStream(file));
bfw.write(b);
}catch(IOException e)
{
e.printStackTrace();
}finally
{
try {
bfw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void apply(File file,File file1)
{
byte b[] = cut(file1);
paste(b,file);
if(file1.exists())
file1.delete();
else
System.out.println("该图片已删除");
}
public static void main(String args[])
{
File file = new File("D:\\2\\2.jpg");//图片要被粘贴的位置,图片名字必须要写,不然会报错
File file1 =new File("D:\\photo\\2.jpg");//被剪切的图片
apply(file,file1);
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1 {
/*
*
* 实现对某一个图片的剪切和粘贴
*
*/
public static byte[] cut(File file)//剪切
{
BufferedInputStream bfd = null;
byte[]b =null;
try
{
bfd = new BufferedInputStream(new FileInputStream(file));
b = new byte[bfd.available()];
bfd.read(b);
}catch(FileNotFoundException e)
{
e.printStackTrace();
}catch(IOException e)
{
e.printStackTrace();
}
finally
{
try {
bfd.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return b;
}
public static void paste(byte[]b,File file)//粘贴
{
BufferedOutputStream bfw = null;
try
{
bfw = new BufferedOutputStream(new FileOutputStream(file));
bfw.write(b);
}catch(IOException e)
{
e.printStackTrace();
}finally
{
try {
bfw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void apply(File file,File file1)
{
byte b[] = cut(file1);
paste(b,file);
if(file1.exists())
file1.delete();
else
System.out.println("该图片已删除");
}
public static void main(String args[])
{
File file = new File("D:\\2\\2.jpg");//图片要被粘贴的位置,图片名字必须要写,不然会报错
File file1 =new File("D:\\photo\\2.jpg");//被剪切的图片
apply(file,file1);
}
}
0 0
- 用流对图片进行剪切,粘贴
- android 从sdcard 读取图片并进行剪切,粘贴操作
- 对图片进行批处理剪切成需要的大小
- 对图片指定位置剪切
- IOS手机中图片的复制粘贴,剪切
- JAVA实现对图片的剪切
- android 复制、剪切、粘贴
- android 复制、剪切、粘贴
- android 复制、剪切、粘贴
- android 复制,剪切,粘贴
- CTreeCtrl 右键剪切,粘贴
- vi复制粘贴剪切
- android调用系统相册选图或相机拍照后对图片进行剪切无内存溢出支持7.0
- 图片剪切
- 图片剪切
- 图片剪切
- 图片剪切
- 对Worksheet_SelectionChange事件写入代码后影响Excel剪切、复制粘贴的修正
- spring boot整合redis
- SpringBoot非官方教程 | 第十篇: 用spring Restdocs创建API文档
- spark厦大----KMeans聚类算法 -- spark.mllib
- activemq的负载配置
- DWR3.0(3)ScriptSession的维护及优化
- 用流对图片进行剪切,粘贴
- hive beeline连接hiveserver2
- 1
- ES6为字符串做了哪些扩展?
- 数据结构基础--单链表
- 编程求具有abcd=(ab+cd)²性质的4位数
- 一个漂亮的登陆页面(无图片 只有一个CSS实现的)
- Easy-18
- JavaScript的原型与原型链