LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2004, 11:23 PM   #1
zeviddalop
Member
 
Registered: Sep 2004
Location: bozeman, montana
Distribution: mandrake
Posts: 32

Rep: Reputation: 15
java - how do you input from the command line


i'm kinda perplexed, i've got a project for school where we're supposed to write a driver to allow piped input/output : for ex, driver < inputFile1 > outputFile but for a variety of input files. i can't figure out how to code this without specifically including the input file in the driver. can anyone help?
 
Old 11-10-2004, 12:02 AM   #2
zeviddalop
Member
 
Registered: Sep 2004
Location: bozeman, montana
Distribution: mandrake
Posts: 32

Original Poster
Rep: Reputation: 15
no worries, got it figured out.
 
Old 11-10-2004, 06:26 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
The answer to the question is to use the System.in and System.out streams.

Please post the answers to your questions if you find out what they are; that way other people can benefit from your insight.

Well done on fixing it, though
 
Old 11-10-2004, 07:29 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I think zeviddalop meant take arguments when calling 'java' to exec the program. If that is the case, it is almost like C++:

class App
{
public static void main(String[] args)
{
//all command line arguments are stored in 'args'; just use it like a normal array
//(the exec name isn't given in [0], unlike C++)
}
}
 
Old 11-10-2004, 11:59 AM   #5
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
If i were to read by lines, I would do:
Code:
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
keyboard.readLine();
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding password in Java command line program simon_w Programming 2 05-02-2005 06:01 AM
Java GUI via command line sessions? Giles Linux - General 2 09-28-2004 09:03 AM
run java programs from the command line...howto? rmanocha Programming 3 03-06-2004 02:50 AM
calling command line functions in java darthczyz Programming 2 12-09-2003 07:01 AM
Command line arguments to java program Majjj Programming 3 10-23-2003 05:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration