Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void deleteDataFromFile(String title, String Date) {
- try {
- //open the file
- FileInputStream myIn= openFileInput(FILENAME);
- //the reader given the input file stream.
- InputStreamReader inputReader = new InputStreamReader(myIn);
- //Aftert he inputstream is open, need also a bufferedReader
- BufferedReader BR = new BufferedReader(inputReader);
- //holds a line of input
- String line;
- //used for only erasing one date.
- int counter = 0;
- while ((line = BR.readLine()) != null && counter < 1) {
- if (line.equals(title)) {
- line.replace(title, "" + "n");
- line = BR.readLine();
- line.replace(Date, "" + "n");
- counter++;
- }
- }
- BR.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment