RandomAccessFile $B$N%5%s%W%k(BRevised: Mar./16th/2002
$B
$B$^$?!":G8e$K%U%!%$%k%]%$%s%?$r@hF,$KLa$7$F!"A4$F$NJ8;z$rFI$_9~$s$GI8=`=PNO$K=PNO$7$F$$$^$9!#(B
Append.java:
import java.io.*;
class Append {
public static void main (String[] args) throws IOException {
// RandomAccessFile $B$N%$%s%9%?%s%92=(B
RandomAccessFile raf = new RandomAccessFile(args[0], "rw");
// $B%U%!%$%k$ND9$5$Nlength();
// $B%U%!%$%k%]%$%s%?$rKvHx$K%;%C%H(B
raf.seek(len);
// $B%U%!%$%k$K=q$-9~$_(B
for (int i = 1; i < args.length; i++) {
raf.writeUTF(args[i] + " ");
}
raf.writeUTF("\n");
// $B%U%!%$%k%]%$%s%?$r@hF,$K%;%C%H(B
raf.seek(0L);
try {
while (true) {
// $BJ8;z$NFI$_9~$_(B
String cha= raf.readUTF();
// $BI8=`=PNO$X=PNO(B
System.out.print(cha);
}
} catch (EOFException eofe) {
// $B%U%!%$%k=*N;$G(B EOFException $BH/@8(B
System.out.println();
System.out.println("$B%U%!%$%k=*N;(B [EOF]");
}
// RandomAccessFile $B%9%H%j!<%`$rJD$8$k(B
raf.close();
}
}
C:\IO>javac Append.java C:\IO>java Append test.txt MACBETH MACBETH C:\IO>java Append test.txt Though Birnam wood be come to Dunsinane, MACBETH Though Birnam wood be come to Dunsinane, $B%U%!%$%k=*N;(B [EOF] C:\IO>java Append test.txt And thou opposed, being of no woman born, MACBETH Though Birnam wood be come to Dunsinane, And thou opposed, being of no woman born, $B%U%!%$%k=*N;(B [EOF] C:\IO>java Append test.txt Yet I will try the last. MACBETH Though Birnam wood be come to Dunsinane, And thou opposed, being of no woman born, Yet I will try the last. $B%U%!%$%k=*N;(B [EOF] C:\IO>java Append test.txt MACBETH Though Birnam wood be come to Dunsinane, And thou opposed, being of no woman born, Yet I will try the last. $B%U%!%$%k=*N;(B [EOF] C:\IO>java Append test.txt $B%[!<%k%G%s!&%3!<%k%U%#!<%k%I!*(B MACBETH Though Birnam wood be come to Dunsinane, And thou opposed, being of no woman born, Yet I will try the last. $B%[!<%k%G%s!&%3!<%k%U%#!<%k%I!*(B $B%U%!%$%k=*N;(B [EOF] C:\IO>java Append test.txt $B%S%j!$BFI$_
$B>e$G:n$C$?%U%!%$%k$rFI$_9~$`$@$1$N%5%s%W%k$r5s$2$F$*$-$^$9!#(B
Page.java:import java.io.*; class Page { public static void main (String[] args) throws IOException { // RandomAccessFile $B$N%$%s%9%?%s%92=(B RandomAccessFile raf = new RandomAccessFile(args[0], "r"); try { while (true) { // $BJ8;z$NFI$_9~$_(B String cha= raf.readUTF(); // $BI8=`=PNO$X=PNO(B System.out.print(cha); } } catch (EOFException eofe) { // $B%U%!%$%k=*N;$G(B EOFException $BH/@8(B System.out.println(); System.out.println("$B%U%!%$%k=*N;(B [EOF]"); } // RandomAccessFile $B%9%H%j!<%`$rJD$8$k(B raf.close(); } }C:\IO>javac Page.java C:\IO>java Page test.txt MACBETH Though Birnam wood be come to Dunsinane, And thou opposed, being of no woman born, Yet I will try the last. $B%[!<%k%G%s!&%3!<%k%U%#!<%k%I!*(B $B%S%j!
Copyright © 2002 SUGAI, Manabu. All Rights Reserved.
SEO 仕事 花 掲示板 レンタルサーバー プロフ SEO