wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes gettin error with TextReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "gettin error with TextReader" Watch "gettin error with TextReader" New topic
Author

gettin error with TextReader

neha gautam
Ranch Hand

Joined: Mar 31, 2009
Posts: 32
hi all..

here is the code i m tryin to execute its givin me the error with TextReader..
i can figure why..



the error is:



C:\neha>javac WordCount.java
WordCount.java:20: cannot find symbol
symbol : class TextReader
location: class WordCount
static TextReader in; // An input stream for reading the input file.
^
WordCount.java:137: cannot find symbol
symbol : class TextReader
location: class WordCount
static void readWords(TextReader inStream, Map words) {
^
WordCount.java:121: cannot find symbol
symbol : class TextReader
location: class WordCount
in = new TextReader(new FileReader(args[0]));
^
WordCount.java:176: package TextReader does not exist
catch (TextReader.Error e) {
^
Note: WordCount.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors



i don know what i m missin.....
please help..
thanks to all
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Neha,

TextReader is not standard Java API packaged in JDK. I guess you are trying to use JSci.io.TextReader or your own TextReader class ? anyways you got import it .

Add the jsci jar and import TextReader in the java.
neha gautam
Ranch Hand

Joined: Mar 31, 2009
Posts: 32
thanks balu......

ill try that out
neha gautam
Ranch Hand

Joined: Mar 31, 2009
Posts: 32
even by importin its givin same error on compliation
i jus appended the progrm with:

import java.JSci.io.TextReader;


do i need to anyother thing except this
actually i hv to read my text file word by word
can you guys suggest some other way for the same.
thanks to all
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



import java.JSci.io.TextReader;


Like i mentioned earlier , we don't have any idea of which TextReader Class you are using. I guessed it as "JSci.io.TextReader" and you used "java.JSci.io.TextReader" , where java comes from.


actually i hv to read my text file word by word
can you guys suggest some other way for the same.


I can think of RandomAccessFile which can read line by line. Does that suffice ?
neha gautam
Ranch Hand

Joined: Mar 31, 2009
Posts: 32
thank you for the response balu..

textreader is not my own class but java predefined input stream..
i have read the file word by word,,,,
and not line by line...
its like the text file of the form

0.300, -124.87,
0.362, -127.36,
0.425, -129.30,
0.487, -131.52,
0.549, -133.48,
0.612, -135.43,
0.674, -137.19,
0.736, -138.74,
0.798, -140.21,
0.861, -141.52,
0.923, -142.71,
0.985, -143.86,
1.048, -144.94,
1.110, -146.01,
1.172, -146.87,
1.235, -147.60,
1.297, -148.74,
1.359, -149.45,
1.422, -150.16,
1.484, -151.03,
1.546, -151.56,
1.609, -152.31,
1.671, -152.99,
1.733, -153.76,
1.796, -154.51,
1.858, -155.06,


and my job is to read the file and display a graph between the 1st and 2nd colmns
as X and Y axis, i have my graph prgm, jus had prblm in readin the contents..
so i thought the option of reading the file word by word and storin the colmnsin separate arrays and linkin
them with graph prgrams..
kindly correct me if you think i m wrong somewhr..
thanks for all your help
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



and my job is to read the file and display a graph between the 1st and 2nd colmns
as X and Y axis, i have my graph prgm, jus had prblm in readin the contents..


You could still use RandomAccessFile readLine() method() and could use StringTokenizer or spilt() method with delimiter as "space" or "comma". This way you could get word by word and store in arrays or other preferred approach you are after.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42359
    
  64
Balu Sadhasivam wrote:You could still use RandomAccessFile readLine()

RandomAccessFile really isn't the right class to use here; it's meant for circumstances that have no bearing on this case. A BufferedReader combined with a FileReader would be much more appropriate.


Ping & DNS - my free Android networking tools app
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



A BufferedReader combined with a FileReader would be much more appropriate.


Yes, as long it has readLine() to read it easily.
jennifer pandian
Greenhorn

Joined: Dec 06, 2010
Posts: 1
hey neha.. I am working on a program similar to yours.. did you happen to correct your previous errors? if so, could you please post the corrected program ? It would be very useful to me.. Thanks
Surinder Mehra
Ranch Hand

Joined: Aug 06, 2013
Posts: 32
    
    1
This is probably too late to post an answer. But still for future if required, We can read this file using Scanner and split the line by comma and store the two columns into two lists. Sample is given below:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: gettin error with TextReader