943,983 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2563
  • Java RSS
Nov 30th, 2004
0

Reading in a file.

Expand Post »
Ive been given this code as part of a lexical analyser for which i will be coding a syntax analyser - however the file the lexical analyser will be reading will come throught this code:

public static void main(String[] args) throws IOException
{
BufferedReader din = new BufferedReader(new InputStreamReader(System.in)) ;
System.err.print("file? ") ;
System.err.flush() ;
String fileName = din.readLine().trim() ;
LexicalAnalyser lex = new LexicalAnalyser(fileName) ;
} // end of class LexicalAnalyser

The thing is - where is the path name meant to go? It works by replacing fileName however im not so sure why my lecturer has coded the bufferedreader and inputstreamreader
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
MrScruff is offline Offline
89 posts
since Nov 2004
Nov 30th, 2004
0

Re: Reading in a file.

You type in the filename and path from the console when you run th code. Isn't that what System.in is? I don't know I've never used it.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Nov 30th, 2004
0

Re: Reading in a file.

yup. What I find rather troublesome is that he uses System.err for non-error output...
It would be much preferred to read the inputfile through the commandline.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: missing return statement 106 and 123, any ideas??
Next Thread in Java Forum Timeline: How to invoke array varibles to another main method





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC