Forums Register Login

JAVA FILE INPUT/OUTPUT

+Pie Number of slices to send: Send
Hi,
Could anybody please supply me (or let me know) the full .java source code to do the following:
Open up a simple text area window where the user is asked to type in there name. The user types there name in, clicks an 'ok' button and there name is then written to the file 'name.txt' on the local c:\.
Its for part of a coursework Im doing at college. I would be grateful if someone could let me know the code or even better email me the .java file(s). Im using Java Developement Kit Ver 1.1.8 (the 9mb one u get free from from javasoft).
Regards,
Phil,
HiOnMaiden@FreeNet.co.uk
+Pie Number of slices to send: Send
Philip:
Please give us a little history. Which classes in the Java API are you planning on using? What have you attempted so far? What error message(s) did you get?
Art
+Pie Number of slices to send: Send
Well to be honest its my my first Java assignment. Ive got 2 months to do it but I know bugger all about Java @ moment.
The Java I/O is the main part of it really. If I can get Java file I/O working (just creating files on local hard drive/reading em back) then as I say the rest is just putting the I/O code into a Java user interface. I dont even have to send any files across net/intranet or anything - for the demo I need to give just on a standalone PC will do.
Im working thru the book 'core java 1.2 - Fundamentals' but nothing seems to work in chap12 (the one relavent for me!).
I figure everything needed is in the java.io class but Ive no idea were to begin and I cant find any SIMPLE java I/O examples similar to what I need on net anywhere.
Regards,
Phil.
+Pie Number of slices to send: Send
I'm a little puzzled by your request. Presumably the aim of the coursework is that you do it yourself. Would you really learn as much by just copying one which someone else has written?
I'm sure we would all like to help you get the most from your course, but some things I reckon you have to at least try to do yourself. If this is not the case, please let us know. I'm sure many people here could knock up such a thing very quickly.
+Pie Number of slices to send: Send
OOps, you replied with more detail as I was composing that last one. You say that the examples are not working - what sort of errors are you getting? If we can get the examples working for you, then the rest should be easy. It may just be some small misunderstanding which is holding you up.
+Pie Number of slices to send: Send
Phil,
You can take a look at the I/O forum and look through the posts in the last year and find some simple examples I am sure. Writing to a file is very simple, and it would be a great experience for you to figure it out.
People here will be willing to work with you--even your most basic, seemingly idiotic questions. Everyone starts out somewhere. However, few people really want to rob you of a valuable learning experience, no matter how easy it would be for them to just give you some code.
Do you have a java environment set up? That is a good first step, if you haven't done it, but it sounds like you have. Once you are able to write and run the most basic java programs writing out to the screen through println() , you only have a few more steps to writing to a text file. And this won't be an applet in all likelihood, so concentrate on little Java apps in your tutorial/books. It really won't take too long for you to figure out how to do it--really understanding what's going on is what takes awhile.
OP
+Pie Number of slices to send: Send
First you need to decide - are you going to do this as an applet (run from a browser so you need an HTML page), or as an application run from the command prompt (it matters). I am assuming that you are not yet to servlets etc.
Next you need to understand that there are going to be alot of examples using SWING GUIs. The version of java that you are using does not fully support swing even with a plug-in, so you will need to use the AWT for your GUI. (avoid all the JXXXXX classes).
Start out just getting an empty frame to come up.
Then add a TextField and Button to it.
Then add a Listener so your button hears when you are ready.
Last worry about IO.

[This message has been edited by Cindy Glass (edited April 05, 2001).]
+Pie Number of slices to send: Send
PS: all the versions are free. Are you allowed to use the 1.3 version? It's much better .

Get the Java 2 SDK SE (Standard Edition) from Sun at: http://www.sun.com/download/
look! it's a bird! it's a plane! It's .... a teeny tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1097 times.
Similar Threads
NT authentication using servlets..
Reading parameter from JSP page
copying file from client system to and storing in server
Is this policy file correct?
Reading .gif Images from a file
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:01:58.