Advertisement
Plabon_dutta

File I/O Problem Java

Nov 20th, 2021
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. package problem3;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7.  
  8. public class File {
  9.  
  10.     public static void main(String[] args) {
  11.         String[] words = null;
  12.         String s;
  13.         int flag;
  14.         char ch,ch1;
  15.         BufferedReader br = null;
  16.         try {
  17.             br = new BufferedReader(new FileReader("input.txt"));
  18.         } catch (FileNotFoundException e) {
  19.             e.printStackTrace();
  20.         }
  21.        
  22.         try {
  23.             while ((s = br.readLine()) != null) {
  24.                 //System.out.println(s);
  25.                 words = s.split(" ");
  26.                 for (int i = 0; i < words.length; i++) {
  27.                     flag = words[i].length();
  28.                     if (flag >= 7) {
  29.                         ch = words[i].charAt(0);
  30.                         ch1 = words[i].charAt(flag - 1);
  31.                         if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
  32.                             if (ch1 == 'a' || ch1 == 'e' || ch1 == 'i' || ch1 == 'o' || ch1 == 'u') {
  33.                                 System.out.println(words[i]);
  34.                             }
  35.                         }
  36.                     }
  37.  
  38.                 }
  39.             }
  40.  
  41.         } catch(IOException e) {
  42.             e.printStackTrace();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement