Skip to content

Instantly share code, notes, and snippets.

@diabloneo
Created October 22, 2014 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diabloneo/705521c6529206c3111b to your computer and use it in GitHub Desktop.
Save diabloneo/705521c6529206c3111b to your computer and use it in GitHub Desktop.
Process home directory in Java.
/**
* 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);
}
}
}
@diabloneo
Copy link
Author

Of course, you should consider about security problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment