Paste Search Dynamic
Recent pastes
pathToFile
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class main
  9. {
  10.         public static void main (string[] args) throws java.lang.exception
  11.         {
  12.                  string pathToFile = "C:\dat.txt";     
  13.         // String current = new java.io.File( "." ).getCanonicalPath();
  14.         system.out.println("Current dir:"+system.getProperty("user.dir"));
  15.          
  16.          file file = new file(pathToFile);
  17.        
  18.          if (file.exists())
  19.             system.out.println("Exists");
  20.      else
  21.             system.out.println("Does not Exists");      
  22.      int c = 0;
  23.      int t = 0;
  24.      int num;
  25.     try (Scanner scan = new Scanner(file)) {
  26.         while (scan.hasNext()) {
  27.             num = integer.parseInt(scan.next());
  28.             if (num >= 9999) {
  29.                         c++;
  30.             }    
  31.     }
  32.     system.out.println(c +"    t=" + t);
  33. } catch (filenotfoundexception e) {
  34.     system.out.println("No file found: " + pathToFile);
  35. }
  36.         }
  37. }
Parsed in 0.029 seconds