私はおそらくこの質問にあまりにも長い時間を費やしましたが、:
C:\temp>notepad test_in.txt =>
こんにちはJava入力!
同じディレクトリに「Test.java」を作成します。
package com.mytest;
import java.io.*;
public class Test {
public static void main (String [] args) throws IOException {
System.out.println ("Current directory is " + new File(".").getAbsolutePath());
System.out.println ("Reading file " + INPUT_FILE + "...");
BufferedReader fis =
new BufferedReader(new FileReader(INPUT_FILE));
String s = fis.readLine ();
fis.close ();
System.out.println ("Contents: " + s + ".");
System.out.println ("Writing file " + INPUT_FILE + "...");
PrintWriter fos =
new PrintWriter(new BufferedWriter(new FileWriter("test_out.txt")));
fos.println ("Hello Java output");
fos.close ();
System.out.println ("Done.");
}
private static final String INPUT_FILE = "test_in.txt";
private static final String OUTPUT_FILE = "test_out.txt";
}
最後に、それを実行します-完全なパッケージ名を指定します:
C:\temp>javac -d . Test.java
C:\temp>dir com\mytest
Volume in drive C has no label.
Volume Serial Number is 7096-6FDD
Directory of C:\temp\com\mytest
05/17/2012 02:23 PM <DIR> .
05/17/2012 02:23 PM <DIR> ..
05/17/2012 02:29 PM 1,375 Test.class
1 File(s) 1,375 bytes
2 Dir(s) 396,478,521,344 bytes free
C:\temp>java com.mytest.Test
Current directory is C:\temp\.
Reading file test_in.txt...
Contents: Hello Java input!.
Writing file test_in.txt...
Done.
C:\temp>dir/od test*.txt
Volume in drive C has no label.
Volume Serial Number is 7096-6FDD
Directory of C:\temp
05/17/2012 02:24 PM 17 test_in.txt
05/17/2012 02:29 PM 19 test_out.txt
2 File(s) 36 bytes
'次のようないくつかのことを説明するのに役立つことを願っています。