This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes getting data from command line. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting data from command line." Watch "getting data from command line." New topic

getting data from command line.

Branden Bobo

Joined: Jul 16, 2012
Posts: 15
Is there a simple pre-build class (as of java 7) to read text from the command line?
If not... I wrote my own re-usible helper class... Is this a good approach is there a better way?

p.s. this is my first post on any forum ever so please be nice.
Greg Brannon

Joined: Oct 24, 2010
Posts: 557
Are you aware of Scanner? You can also find many examples of how to use Scanner to do what I think you're trying to do, but I may not understand your question.

Two of the many cool things about Java is that the Core Java API is so rich and that there are many third party libraries that do most anything else the core libraries do not do, or, in some cases, do the same thing only better. I'll relay what I was told early in my Java study, "Don't reinvent the wheel." Instead, I suggest you learn from the inventors who've blazed the trails.

Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Branden Bobo

Joined: Jul 16, 2012
Posts: 15
Thank you I was not familiar with the Scanner class.
I'm coming from C# so although I've been able to pick the java language quickly,
but I know very little about most of the libraries (of coarse i'm trying to change that.)
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340

don't feel bad. i have several years of java experience, but it was before Scanner class. i have to learn about it too.

Visit my download page
Greg Brannon

Joined: Oct 24, 2010
Posts: 557
That's cool. Just ask if you have similar, "How do I . . .?" questions. Most basic Java tutorials/books will introduce you to the fundamental classes. Some free books and cheat sheets are available online from which you could quickly cross reference your existing programming knowledge by scanning the reference's Table of Contents.

You should also be aware of the online Java Tutorials that usually come up if you Google a Java topic. For example, if you Google "java input" the first result is the Java Basic I/O Tutorial that covers many I/O topics, including Scanner.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: getting data from command line.
Similar Threads
help with running dos commands using java
we ask for user input in c by writing & (ampersand) but how to achieve this in java ?
Please tell me what is wrong with read method(or the way i am using it).
Communicating with unix command process from java using stream