This is my input file:
This is a file test.
please take
notice of it.
Peace.
and this is the output:
This is a file test.
please take
notice of
I do not understant why it stops and "it." ,but it displays the word "test.". Here's the code:
import java.io.*;
import java.util.*;
public class FileTest {
public static void readFile() throws Throwable {
File _output = new File("output.txt");
FileWriter _filewr = new FileWriter(_output);
BufferedWriter _buffwrt = new BufferedWriter(_filewr);
FileInputStream f = new FileInputStream(
"C:\\Users\\Diana\\Desktop\\FileTest\\test.txt.txt");
BufferedReader _buffer = new BufferedReader(new InputStreamReader(f));
String _str = _buffer.readLine();
while (_str != null) {
String[] _vect = _str.split(" ");
int i;
for (i = 0; i < _vect.length; i++) {
if (_vect[i].contains(".")) {
_buffwrt.write(_vect[i] + " ");
break;
}
else
_buffwrt.write(_vect[i] + " ");
_buffwrt.flush();
}
_str = _buffer.readLine();
}
}
public static void main(String[] args) throws Throwable {
readFile();
}
}