LearningSlowly
LearningSlowly

Reputation: 9451

Finding current username with scala

I wish to find the current username in scala.

On the command line I can do:

whoami 

In python, I can do:

import getpass
user_name = getpass.getuser()

How do I find the username in Scala?

Upvotes: 7

Views: 4599

Answers (1)

Tzach Zohar
Tzach Zohar

Reputation: 37852

You can use the Java API for this:

System.getProperty("user.name")

See more (Java) options here: Get login username in java

Upvotes: 13

Related Questions