Skip to content

Instantly share code, notes, and snippets.

@johanrovala
Created March 9, 2015 10:58
Show Gist options
  • Save johanrovala/3c3d6c29ffbedbc566e1 to your computer and use it in GitHub Desktop.
Save johanrovala/3c3d6c29ffbedbc566e1 to your computer and use it in GitHub Desktop.
Min getWords-metod. Villkoren definierar vad som är ett ord och av någon anledning som förmodligen bör finnas här får jag ett ord för mycket.
public void getWords(){
String str = "";
String del = "[;.,:'!?()\"+=*]";
n.useDelimiter(del);
while(n.hasNext()){
str += n.next();
}
str = str.replace('-', ' '); // because of people like Al Jazari
str = str.replaceAll("[0-9]","");
System.out.println(file.getPath());
System.out.print(str);
File newFile = new File("C:\\Users\\Johan\\Desktop", "justWords.txt");
try {
FileWriter write = new FileWriter(newFile);
write.write(str);
write.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment