|
Post by CooLiBoP on Nov 3, 2001 15:33:21 GMT -5
I ran into a little snag while working on #6 and #7...If my file has an enter (i.e. if I type "alkjdlakjsdlkjldl *enter* alsdkjlaksjl" in the input file) it will stop reading up to the enter and won't read the rest of the file...I was just wondering how other people got around this
|
|
|
Post by Sky on Nov 3, 2001 16:01:07 GMT -5
did u use a loop to read the file line by line one after another? ie. while ( !(inputLine==null) ){ ... } something like that la...
|
|
|
Post by CooLiBoP on Nov 3, 2001 19:36:28 GMT -5
Nope =\
The way I did it reads character by character...
|
|
|
Post by Majin_Blues on Nov 3, 2001 22:07:46 GMT -5
well you have to do that too, but you also have to make a loop to repeat reading each line in the text file on top of looking through each character... (that is, nested loops)
|
|
|
Post by CooLiBoP on Nov 4, 2001 11:47:16 GMT -5
so how does it know when the end of the line is?
|
|
|
Post by Sky on Nov 4, 2001 12:33:41 GMT -5
at the end of the line the reader will return null...use sometihing like !(line == null) as your while condition...it's on the other board too...
|
|
|
Post by CooLiBoP on Nov 4, 2001 12:37:18 GMT -5
!(line == null) gives me a null pointer exception?!!? what the heck...I'm so confused now...Oh and how does it know its at the end of the file then?
|
|
|
Post by Majin_Blues on Nov 4, 2001 12:52:56 GMT -5
at the end of the line the reader will return null...use sometihing like !(line == null) as your while condition...it's on the other board too... don't u mean at the end of the file? at the end of a line, won't it return the character for pressing "return/enter"? EDIT: sorry.. it's null for both file and line for coolibop: it should work fine... unless you put in !line.equals(null) instead... either that or you had a readline command after your while loop ended? (just a guess)
|
|
|
Post by Sky on Nov 4, 2001 12:59:01 GMT -5
when i said end of the line...i actually mean at the end of the file <sorry about that>...so it will give u null at the end of the file when it finish reading every line...u'll be ok now...i guess but u'll need to use another loop inside the pervious loop to check every line if it has a capital letter... and to give more hints...u may need to use a boolean to make sure u don't print the same line more than one time when the line contains more than one capital letter
|
|
|
Post by bladehunter on Nov 4, 2001 13:00:21 GMT -5
I don't understand the rules here.
It says for classes L6 and L7, we do not specify a file path and put the test files in the same directory as the .class files.
But when I run my program, it assumes that file is in C: and gives me "No File" error. When I input the full path, it works perfectly.
Is that what they want us to do? Can they get more ambiguous than this?
|
|
|
Post by Majin_Blues on Nov 4, 2001 13:05:03 GMT -5
that's what they're gonna do: they'll input the full directory the file is in, which is why they don't want people setting some default directory that might not exist on their autotester
|
|
|
Post by Sky on Nov 4, 2001 13:07:53 GMT -5
u can try put the input file in the same folder as your folder for assignment 6. That's what they mean by the same directory...so u may just input the name of the file without the file path this way
|
|
|
Post by bladehunter on Nov 4, 2001 13:08:51 GMT -5
Problem is, it doesn't work if i do that
|
|
|
Post by Griever on Nov 5, 2001 18:31:08 GMT -5
Don't forget to include the extension. ie. check.txt
|
|
|
Post by Brutal_Chicken on Nov 6, 2001 20:17:57 GMT -5
Quick question; how do I get the filereader to move onto the next line? Say after you have the command to print out the line then the next line should deal with moving onto the next line in the text.
|
|