September 04, 2010, 12:52:36 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Retrieve the directory of the currently logged in user. (Windows only)  (Read 896 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: April 28, 2009, 05:10:52 AM »

Code
GeSHi (java):
  1. /*--------------------------------------------------------------------------
  2. OpenFolder.java
  3. *****************
  4. By: HappyFace http://www.engineeringserver.com
  5. Contact: info [@] engineeringserver.com
  6. Version: 28/april/2009
  7. "*****************
  8. Note: Retrieve the directory of the currently logged in user. (Windows only)
  9. //----------------------------------------------------------------------*/
  10. import java.awt.Desktop;
  11. import java.io.File;
  12.  
  13. public class OpenFolder {
  14.  
  15. public static void main(String[] args) throws Exception {
  16. File dir = new File(System.getProperty("user.home"));
  17. String userName = System.getProperty("user.name");
  18. System.out.println("Logged in user: "  + userName);
  19. System.out.println("Opening the user directory in 2 seconds.");
  20. Thread.sleep(2000);
  21. Desktop.getDesktop().open(dir);
  22. }
  23. }
  24.  
Created by GeSHI 1.0.7.20
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: April 28, 2009, 05:10:52 AM »

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.188 seconds with 32 queries.

Google visited last this page September 01, 2010, 04:04:51 AM