赋值图片例子:
import java.io.*;
class CopyMp3
{
public static void main(String[] args)
{
CopyPic();
}
public static void CopyPic()
{
FileInputStream fileInput = null;
FileOutputStream fileOutput = null;
try
{
fileInput = new FileInputStream("C:\\1.jpg");
fileOutput = new FileOutputStream("C:\\2.Jpg");
BufferedInputStream bufInput = new BufferedInputStream(fileInput);
BufferedOutputStream bufOutput = new BufferedOutputStream(fileOutput);
byte [] bt = new byte[1024];
int len = 0;
while((len = bufInput.read(bt)) != -1)
{
bufOutput.write(bt);
bufOutput.flush();
}
}
catch (IOException ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(fileInput != null)
{
fileInput.close();
}
if(fileOutput != null)
{
fileOutput.close();
}
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
}
}