Reading in a file.

Reply

Join Date: Nov 2004
Posts: 89
Reputation: MrScruff is an unknown quantity at this point 
Solved Threads: 0
MrScruff's Avatar
MrScruff MrScruff is offline Offline
Junior Poster in Training

Reading in a file.

 
0
  #1
Nov 30th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Reading in a file.

 
0
  #2
Nov 30th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Reading in a file.

 
0
  #3
Nov 30th, 2004
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC