Java Question

CrackaLackaZe

Senior member
Jun 29, 2002
922
0
76
How do you create a simple java program to save a string to a file, exit the program, then run the program again with the string loaded from that file?
 

eklass

Golden Member
Mar 19, 2001
1,218
0
0
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.
 

eklass

Golden Member
Mar 19, 2001
1,218
0
0
Originally posted by: Kilrsat
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.

if he understands the concept of programming, it should point him in the right direction

if he doesn't he should have been more specific
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.

if he understands the concept of programming, it should point him in the right direction

if he doesn't he should have been more specific

It won't point him in the right direction because of basic java io being completely stream based, the lack of needing real file pointers, and cryptic C shortcuts such as "while(!feof(fp))".

If you actually knew what the java solution looked like, you would realize just how useless what you gave him was. The best thing he can do is start reading the Sun introduction to java streams, it will walk him from how to read/write from the keyboard/screen into how to read/write from files (which just happen to be nearly identical).
 

eklass

Golden Member
Mar 19, 2001
1,218
0
0
Originally posted by: Kilrsat
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.

if he understands the concept of programming, it should point him in the right direction

if he doesn't he should have been more specific

It won't point him in the right direction because of basic java io being completely stream based, the lack of needing real file pointers, and cryptic C shortcuts such as "while(!feof(fp))".

If you actually knew what the java solution looked like, you would realize just how useless what you gave him was. The best thing he can do is start reading the Sun introduction to java streams, it will walk him from how to read/write from the keyboard/screen into how to read/write from files (which just happen to be nearly identical).


instead of wasting your time complaining, make yourself useful and offer a suggestion/fix/something
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.

if he understands the concept of programming, it should point him in the right direction

if he doesn't he should have been more specific

It won't point him in the right direction because of basic java io being completely stream based, the lack of needing real file pointers, and cryptic C shortcuts such as "while(!feof(fp))".

If you actually knew what the java solution looked like, you would realize just how useless what you gave him was. The best thing he can do is start reading the Sun introduction to java streams, it will walk him from how to read/write from the keyboard/screen into how to read/write from files (which just happen to be nearly identical).


instead of wasting your time complaining, make yourself useful and offer a suggestion/fix/something

Never heard of constructive criticism?
 

znaps

Senior member
Jan 15, 2004
414
0
0
Look into PrintWriters and Readers, or FileOutputStreams wrapping ObjectOutputStreams and the corresponding FileInputStreams/ObjectInputStreams.
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
Originally posted by: Kilrsat
Originally posted by: eklass
psuedocode appears below. i'm not a java expert so no java for you. if it's not right fix it i didn't check it over
That won't even come close to working in java. It won't even point him in the right direction. You might as well have given him the perl solution.

if he understands the concept of programming, it should point him in the right direction

if he doesn't he should have been more specific

It won't point him in the right direction because of basic java io being completely stream based, the lack of needing real file pointers, and cryptic C shortcuts such as "while(!feof(fp))".

If you actually knew what the java solution looked like, you would realize just how useless what you gave him was. The best thing he can do is start reading the Sun introduction to java streams, it will walk him from how to read/write from the keyboard/screen into how to read/write from files (which just happen to be nearly identical).


instead of wasting your time complaining, make yourself useful and offer a suggestion/fix/something
I already gave him the Java IO Tutorial link, a full 14hrs before you offered anything. He'll find knowledge of how java streams work, and code examples that include reading and writing to files there. Did you want me to code the solution or something?

In case you missed it:
Sun Java IO Tutorial
Learn all you need, straight from Sun.

And because I'm nice, another IO tutorial:
Java 103: File-handling under Java