|
|
Исходный текст программы MergeAll.java
|
Оглавление |
Назад
// ==========================================
// MergeAll.java
// (C) Alexandr Frolov, 1998
// E-mail: frolov@glasnet.ru
// Web: http://www.glasnet.ru/~frolov
// ==========================================
import java.io.*;
import java.util.*;
public class MergeAll
{
public static void main(String args[])
{
Vector files;
SequenceInputStream sis;
FileOutputStream fos;
if(args.length > 0)
{
files = new Vector(args.length);
System.out.println("Merge: ");
try
{
for(int i = 0; i < args.length; i++)
{
files.addElement(
new FileInputStream(args[i]));
System.out.println(args[i]);
}
}
catch (FileNotFoundException ex)
{
System.out.println(ex.toString());
System.exit(0);
}
try
{
sis = new SequenceInputStream(
files.elements());
fos = new FileOutputStream(
"!merged.txt");
int b;
while(true)
{
b = sis.read();
if(b == -1)
break;
fos.write(b);
}
sis.close();
fos.close();
}
catch (IOException ex)
{
System.out.println(ex.toString());
System.exit(0);
}
}
else
System.out.println(
"Args: name1 name2 name3 ...");
}
}
|
|
|