当删除isLetter()
方法时,一切正常,但是当我添加它时会出错。我在main方法中删除了私有。请帮忙。提前谢谢。
import java.io.*;
class WordCounter{
public static void main(String args[]){
File file_in_obj = new File("E:/Problems","notes.txt");
File file_out_obj = new File("E:/Problems","notes_sorted.txt");
boolean isLetter(char let){
return ( let>= 'a'&& let <= 'z') || ( let >= 'A' && let <='Z');
}
try(BufferedReader fin = new BufferedReader(new FileReader(file_in_obj));
BufferedWriter fout = new BufferedWriter(new FileWriter(file_out_obj));){
String array[]=new String[500];
char ch[]=new char[25];
int rd,k=0;
String line=null;
/*do{
rd=fin.read();
if(Character.isWhitespace((char)rd))
fout.write(" ");
else if(Character.isLetter((char)rd)){
fout.write((char)rd);
}
}while(rd!=-1); */
while((line=fin.readLine())!=null){
// System.out.println(j++);
String[] tokens = line.split ("\\s+");
for(int i = 0; i < tokens.length; i++){
array[k]=tokens[i];
fout.write(array[k]+" ");
k++;
//System.out.println(tokens.length);
}
}
for(int p=0;p<k;p++){
for(int i=0;i<array[p].length();i++){
if(Character.isLetter(array[p].charAt(i)))
System.out.print(array[p].charAt(i));
}
System.out.println(p);
}
/*for(int j=tokens.length;j>1;j--)
for(int i=0;i<j-1;i++){
if(tokens[i].compareTo(tokens[i+1])>0){
String temp=tokens[i+1];
tokens[i+1]=tokens[i];
tokens[i]=temp;
}
}*/
} catch(IOException e){
System.out.println("I/O Exception occured");
}
}
}
答案 0 :(得分:0)
您无法在其他方法中使用方法。试试这个:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.morphia.MorphiaAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>