blob: eb6557a5d1a47953627295bf8d7e32522736504a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* Listing2002.java */
import java.io.*;
public class Listing2002
{
public static void main(String[] args)
{
try {
RandomAccessFile f1 = new RandomAccessFile(
args[0], "rw"
);
long len = f1.length();
f1.setLength(2 * len);
for (long i = 0; i < len; ++i) {
f1.seek(i);
int c = f1.read();
f1.seek(2 * len - i - 1);
f1.write(c);
}
f1.close();
} catch (IOException e) {
System.err.println(e.toString());
}
}
}
|