Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 7th, 2013  |  syntax: None  |  size: 1.04 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }