Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. private int getShort() throws IOException
  2. {
  3. inFile = new File ("tjefferson.txt");
  4.  
  5. BufferedReader fileIn3;
  6.  
  7. String[] sentences = new String[200];
  8.  
  9. int shortest, shortLocation;
  10.  
  11. String delims = "[?.]";
  12.  
  13. shortLocation = 0;
  14.  
  15. fileIn3 = new BufferedReader( new FileReader ( inFile ));
  16.  
  17. line3 = new String( fileIn3.readLine() );
  18.  
  19. while ( line3 != null )
  20. {
  21. shortest = sentences[0].length();
  22. sentences = line3.split(delims);
  23.  
  24. for (int i = 0; i < sentences.length; i++)
  25. {
  26. if ( sentences[i].length() < shortest )
  27. {
  28. shortest = sentences[i].length();
  29. shortLocation = i;
  30.  
  31. } // end if
  32.  
  33. } // for loop
  34.  
  35. line3 = fileIn3.readLine();
  36.  
  37. } // end while
  38.  
  39. shortest = sentences[shortLocation].length();
  40.  
  41. return shortest;
  42.  
  43. } // getShort method
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement