Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chessboard;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- public class ChessboardOne {
- public static void main (String args[]) {
- try {
- BufferedReader in = new BufferedReader(new FileReader("D:\\Documents and Settings\\Anthony.PEPSI\\Desktop\\Uni\\Workspace\\Coursework\\Board01.txt"));
- String s;
- while ((s = in.readLine()) != null) {
- int count = 0;
- char charSearch = 'p';
- for (int i = 0; i < s.length(); i++) {
- if( s.charAt(i) == charSearch ) {
- count++;}}
- System.out.println("There is: "+count+" p's in this string.");
- }
- in.close();
- } catch (IOException e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement