Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding current username with scala

Tags:

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?

like image 588
LearningSlowly Avatar asked Dec 07 '16 10:12

LearningSlowly


1 Answers

You can use the Java API for this:

System.getProperty("user.name")

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

like image 64
Tzach Zohar Avatar answered Sep 25 '22 22:09

Tzach Zohar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!