私は C++ のバックグラウンドを持っているので、n00bish クエリには親切にしてください...
入力ファイルからデータを読み取り、文字列ストリームに保存したいと思います。文字列ストリームを使用して、C++ で簡単にこれを実現できます。Javaで同じことをしようとして少し迷っています。
以下は、行ごとに読み取ったデータを文字列配列に保存する、私が開発した大まかなコード/方法です。(文字列配列を使用するのではなく) 文字列ストリームを使用してデータをキャプチャする必要があります。
char dataCharArray[] = new char[2];
int marker=0;
String inputLine;
String temp_to_write_data[] = new String[100];
// Now, read from output_x into stringstream
FileInputStream fstream = new FileInputStream("output_" + dataCharArray[0]);
// Convert our input stream to a BufferedReader
BufferedReader in = new BufferedReader (new InputStreamReader(fstream));
// Continue to read lines while there are still some left to read
while ((inputLine = in.readLine()) != null )
{
// Print file line to screen
// System.out.println (inputLine);
temp_to_write_data[marker] = inputLine;
marker++;
}
編集:
私が本当に欲しかったのは StringBuffer だったと思います。ファイルから (おそらく StringBuffer に) データを読み取り、すべてのデータを別のファイルに書き戻す/転送する必要があります。