Created
March 9, 2015 10:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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