Created
October 22, 2014 15:32
-
-
Save diabloneo/705521c6529206c3111b to your computer and use it in GitHub Desktop.
Process home directory in Java.
This file contains 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
/** | |
* Created by diabloneo on 10/1/14. | |
*/ | |
import java.io.IOException; | |
import java.util.Scanner; | |
import java.nio.file.Paths; | |
public class Hello { | |
public static void main(String[] args) { | |
String wordFile = "~/tmp/words"; | |
try { | |
Scanner in = new Scanner(Paths.get(wordFile.replace("~", System.getProperty("user.home")))); | |
while (in.hasNext()) { | |
System.out.println(in.nextLine()); | |
} | |
} catch (IOException e) { | |
System.out.println(e); | |
System.exit(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of course, you should consider about security problem.