Note that there are some explanatory texts on larger screens.

plurals
  1. POusing txt file in eclipse & java
    primarykey
    data
    text
    <p>I'm new to eclipse and Java. I have an H.W assignment and I need to write a class that reads a .txt file.</p> <p>Before simulating I created a file named "in.txt" in my C directory. In run configuration I wrote "C:\in.txt" as an argument.</p> <p>I get this error:</p> <blockquote> <p>java.io.FileNotFoundException: C:\in.txt (The system cannot find the file specified)<br> at java.io.FileInputStream.open(Native Method)<br> at java.io.FileInputStream.(Unknown Source)<br> at java.io.FileInputStream.(Unknown Source)<br> at java.io.FileReader.(Unknown Source)<br> at Flesch.main(Flesch.java:25)</p> </blockquote> <p>I have also tried to write "C:\in.txt" and got the same error.</p> <p>Here is my code:</p> <pre><code>import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException; import java.util.StringTokenizer; public class Flesch { public static void main(String[] args) { if (args.length != 1) { System.out.print("error"); return; } BufferedReader mybuffer = null; try { String my_line; int words_num=0; int senteses=0; int verbs=0; int word_verbs = 0; String word_delimtiters = " ()*&amp;^%$#@!_-=[]{}?;:',."; mybuffer = new BufferedReader(new FileReader(args[0])); while((my_line = mybuffer.readLine())!= null)//reading the liens { //counting the number of words StringTokenizer token = new StringTokenizer(my_line,word_delimtiters); words_num += token.countTokens(); //counting the verbs while (token.hasMoreElements()) { String word = token.nextToken(); word = word.toLowerCase(); word_verbs = 0; boolean last_char_is_verb = false; for (int k=0;k &lt; word.length(); k++ ) { switch (word.charAt(k)) { case 'a': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; case 'e': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; case 'i': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; case 'o': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; case 'u': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; case 'y': if (!last_char_is_verb) word_verbs++; last_char_is_verb = true; break; default: last_char_is_verb = false ; } } if (word_verbs == 0) word_verbs = 1; verbs+= word_verbs; } //counting the number of sentecses for(int i=0;i&lt;my_line.length(); i++) { if(my_line.charAt(i) == '.' || my_line.charAt(i) == ',' || my_line.charAt(i) == ';' || my_line.charAt(i) == '?' || my_line.charAt(i) == '!') { senteses++; } } } double Flesch = 206.835 - 84.6*(verbs/words_num) -1015*(words_num/senteses); System.out.print(Flesch); System.in.read(); } catch(IOException e) { e.printStackTrace(); } finally { try { if (mybuffer != null) mybuffer.close(); } catch(IOException ex) { ex.printStackTrace(); } } } } </code></pre> <p>I've searched the web for this error and didn't found something helpful. I'm feeling as if I'm missing something basic</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload