我希望在选择任何一组public class WordCount {
public static void main(String[] args) throws FileNotFoundException {
while (true) {
System.out.println("Enter File name: ");
Scanner input=new Scanner (System.in);
String fileName= input.nextLine();
FileReader wordReader;
File file = new File("text.txt");
try {
wordReader=new FileReader(fileName);
BufferedReader reader=new BufferedReader(wordReader);
String wordCounter;
int numberWords=0;
double avgWord=0;
double chara=0;
while((wordCounter=reader.readLine()) !=null) {
String []words=wordCounter.split(" ");
for(int i=0;i<words.length;i++)
{
numberWords++;
}
}
while((wordCounter=reader.readLine()) !=null) {
String []charWords=wordCounter.split("");
for (int j=0;j<charWords.length;j++) {
chara++;
}
avgWord=chara/numberWords;
}
System.out.println("Total words: "+ numberWords);
System.out.println("Average word length: "+ avgWord);
}catch (FileNotFoundException ex) {
System.out.println("File not found");
System.out.println("Example of a valid input: /Users/Marcus/Documents/text.txt");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
元素时提交表单。我有:
<li>
使用事件处理程序:
<form class="story_form" id="story_form">
<textarea rows="3" name="story" class="form-control" placeholder="Share a story"></textarea>
<br/>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">about ...
<span class="caret"></span></button>
<ul class="dropdown-menu list-group">
<li class="list-group-item" id="submit_purpose" onclick="story_form.submit();"><a href="#">Our Purpose <span class=" glyphicon glyphicon-question-sign" data-toggle="tooltip" data-placement="top" title={{purpose}}></span></a></li>
<!-- <li class="divider"></li> -->
<li class="dropdown-header">or one of our principles ...</li>
{{#each principles}}
{{> principle}}
{{/each}}
</ul>
</div>
<br/>
</form>
我正在使用第一个Template.inputStory.events({
'submit .story_form'(event) {
console.log(event);
}
});
进行测试,但事件处理程序永远不会被调用。
谢谢, 格伦