Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. String element="AppSample"
  2.  
  3. File file = new File("a.txt");
  4. FileInputStream fis = new FileInputStream(file);
  5. byte[] data = new byte[(int)file.length()];
  6. fis.read(data);
  7. fis.close();
  8. //
  9. String s = new String(data, "UTF-8");
  10.  
  11. if(s.contians(element){ ???Then.....
  12.  
  13. BufferedReader br = null;
  14.  
  15. try {
  16.  
  17. String currentLine;
  18. int count;
  19.  
  20. br = new BufferedReader(new FileReader("a.txt"));
  21.  
  22. while ((currentLine = br.readLine()) != null && currentLine.contains("AppSample")) {
  23. count++;
  24. }
  25.  
  26. } catch (IOException e) {
  27. e.printStackTrace();
  28. } finally {
  29. try {
  30. if (br != null)br.close();
  31. } catch (IOException ex) {
  32. ex.printStackTrace();
  33. }
  34. }
  35.  
  36. System.out.println("Count: "+count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement