Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String element="AppSample"
- File file = new File("a.txt");
- FileInputStream fis = new FileInputStream(file);
- byte[] data = new byte[(int)file.length()];
- fis.read(data);
- fis.close();
- //
- String s = new String(data, "UTF-8");
- if(s.contians(element){ ???Then.....
- BufferedReader br = null;
- try {
- String currentLine;
- int count;
- br = new BufferedReader(new FileReader("a.txt"));
- while ((currentLine = br.readLine()) != null && currentLine.contains("AppSample")) {
- count++;
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (br != null)br.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- System.out.println("Count: "+count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement