首先准备多个txt文件,这里准备了三个:
源代码:
package ls0526;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class All extends Thread
{
private File file;
public All(File file)
{
super();
this.file = file;
}
public void run()
{
InputStream in=null;
OutputStream out=null;
try
{
System.out.println(Thread.currentThread().getName());
in=new FileInputStream(file);
byte[] b=new byte[in.available()];
in.read(b);
out=new FileOutputStream("D:\\JAVA\\素材\\all.txt",true);
out.write(b);
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
/