Hi - In advance thanks! I have figured out how to read a text file and put it into a text area. It is a multi line file that I now need to read one line at a time, parse the line and send it to a database. I have looked through this forum and think that I need a buffered reader and some type of stream reader but when I try to use them I get a error. InputStreamReader aStream = new InputStreamReader(myTextArea); br = new BufferedReader(aStream); return br.readLine(); gives me a constructor error for InputStreamReader. I would really appreciate a few lines of code to get this started. Thanks
What argument does InputStreamReader expect in that constructor? Looks like you're passing it a TextArea and that's what it's complaining about. InputStreamReader javadoc tells you what kind of stream it wants in its constructor. The name it gives you is an interface. If you follow the link to the javadoc for that interface you'll see a list of classes that implement the interface. One of those ought to jump out and grab your attention if you want to read a file. I'm being vague so you can enjoy the hunt. Holler again if that was too vague. Have fun with this!
Well I guess I'm a little dense here. I tried the following; InputStreamReader aStream = new InputStreamReader(InputStream(myTextArea.getText())); BufferedReader br = new BufferedReader(aStream); return br.readLine(); I now get "Error(256,55): method InputStream(java.lang.String) not found in class SNPReader.ReadFrame" I admit that I took intro to Oracle Java last week so I seem to be in over my head so please bear with me.
Old Dog, Welcome to JavaRanch! We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. Thanks Pardner! Hope to see you 'round the Ranch!
Don't forget to use the new keyword when invoking a constructor to initialize a new object. new InputStreamReader(new InputStream(myTextArea.getText()));
Ahh, that's just telling you you're missing "new" in front of the InputStream constructor. Once you get that, I'm betting it will tell you there is no constructor with a string argument. Or that InputStream is abstract (I said interface earlier, my bad) and you can't create one. Look at the JavaDoc for InputStream, "direct known subclasses". See if there is one there that will read a file given the file name. Try that class where you have InputStream. BTW: I'm guessing the textarea contains the name of the file you want to read? Is that right? If it actually contains the text you want to read we have to use a different subclass of InputStream.