Guest User

Untitled

a guest
Feb 7th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. private void deleteDataFromFile(String title, String Date) {
  2.  
  3. try {
  4. //open the file
  5. FileInputStream myIn= openFileInput(FILENAME);
  6. //the reader given the input file stream.
  7. InputStreamReader inputReader = new InputStreamReader(myIn);
  8. //Aftert he inputstream is open, need also a bufferedReader
  9. BufferedReader BR = new BufferedReader(inputReader);
  10.  
  11. //holds a line of input
  12. String line;
  13.  
  14. //used for only erasing one date.
  15. int counter = 0;
  16.  
  17. while ((line = BR.readLine()) != null && counter < 1) {
  18. if (line.equals(title)) {
  19. line.replace(title, "" + "n");
  20. line = BR.readLine();
  21. line.replace(Date, "" + "n");
  22. counter++;
  23. }
  24. }
  25. BR.close();
  26. } catch (FileNotFoundException e) {
  27. e.printStackTrace();
  28. } catch (IOException e) {
  29. e.printStackTrace();
  30. }
  31.  
  32.  
  33. }
Add Comment
Please, Sign In to add comment