package com.hp.Demo5;
import java.io.*;
public class Demo1 {
public static class qq extends Thread {
@Override
public void run() {
System.out.println(this.getName() + "-->上传图片");
for (int i = 0; i <= 5; i++) {
System.out.println(this.getName() + "\t" + (i * 20 + "%"));
try {
qq.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println(this.getName() + "---图片接收完毕");
}
private void Sc() throws IOException {
File file = new File("D:\\ig\\");
String arr[] = file.list();
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
FileInputStream inputStream = new FileInputStream("D:\\ig\\" + arr[i]);
FileOutputStream outputStream = new FileOutputStream("D:\\img\\" + arr[i]);
int a = 0;
while ((a = inputStream.read()) != -1) {
outputStream.write(a);
}
outputStream.close();
inputStream.close();
}
}
public static void main(String[] args) throws IOException {
qq a = new qq();
qq a1 = new qq();
a.Sc();
a.start();
a1.start();
}
}
}
[多线程qq上传图片]
最新推荐文章于 2024-07-20 23:55:03 发布