Quote:
Originally Posted by nogono In a file,line ends with Dot(.)
I want to delete this particular line from file and update the file.. |
I may misunderstood on what you're trying to do, but since you're not giving any scenarios, I'm assuming that you want to remove any lines within a file that ends with Dot (.)
The way to do this is basically reading through the file line by line, then each time you are about to go to the next line, then check if there's a dot at the end of the string...
Code:
BufferedReader br = new BufferedReader(new FileReader("filename.txt"));
String line = br.nextLine(); // this is first line, check it
if (line.charAt(line.length()) == '.') {
// remove the line by replacing the line string by "" string, then append it
} and so forth...
code hasn't been tested, but for your reference... take a look at Java Library for String:
String (Java 2 Platform SE 5.0)
Here's further tutorial on reading from a file:
Tutorial: How to read from ASCII files