my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes I/O stream not working right Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "I/O stream not working right" Watch "I/O stream not working right" New topic
Author

I/O stream not working right

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

The variables x, y, width, height, and adds all are a part in another part of my code, for graphics. Since they are attached to these variables, if something goes wrong, the items do not show up. That part I know for sure is working right. I removed this code and it showed just fine. Anyway here is the output (with no file in the directory):

file1.txt content:

My problem code is below. Here is the begging of my code showing initialization of variables...



I've never completely understood File inputs and outputs (I used to program with Autohotkey), so I'm probably doing everything wrong. Please help me fix this crap I call code.
Thanks,
cc11rocks aka John Price


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

john price wrote:

1) never use == for String comparison. Always use .equals().
2) br.readLine() will read the next line each time it's called. I don't think you want that, but to use the currently read line instead.
3) In that case, the loop already guaranteed that the result is not null, so the second part can be skipped.

The new start of your loop:

One more possible improvement: use a switch instead of the "if check == 0 else if check == 1 ..." part.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Thank you very much. It works 100% now!
,
John Price, aka cc11rocks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I/O stream not working right
 
Similar Threads
JOptionPane. showMessageDialog() problem
problem while displaying multipage tiff image in applet
Want confirmation that I am doing everything right
painting custom components without extending jcomponent
JAR + Saving and Uploading files