62,614
社区成员
发帖
与我相关
我的任务
分享
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = null;
FileOutputStream fos = null;
TreeSet<String> set = new TreeSet<String>();
while (true){
String path = reader.readLine();
if(path.equals("end")||path.equals("结束"))
{
break;
}
set.add(path);
}
while(set.size() > 0){
String path = set.pollFirst();
if (fileName == null) {
fileName = path.substring(0, path.lastIndexOf("."));
fos = new FileOutputStream(fileName);
}
byte[] data = new byte[1024];
int len;
FileInputStream fis = new FileInputStream(path);
while ((len = fis.read(data)) > 0){
fos.write(data, 0, len);
}
fis.close();
}
fos.close();
reader.close();
}
}