• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileInputStream

 
Scott Brooks
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I go again. I am attemptin to create a logon screen. I can create an ID and write to a file. However, I cannot pull the entire contents of the file back into the program to determine whether an ID and password are a match. Please see attached code below.
[ edited to preserve formatting using the [code] and [/code] UBB tags and to reformat code, removing tab characters -ds ]
[ August 21, 2004: Message edited by: Dirk Schreckmann ]
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott,
The code you have posted demonstrates unfamiliarity with java's I/O classes.
In case you haven't already done so, I suggest you peruse the I/O lesson in the java tutorial.

Generally, classes in the "java.io" package, whose names end in "Stream", are for binary files, while classes whose name ends in "Reader" (or "Writer") are for text files. Since it appears you are using a text file, "ObjectOutputStream" and "ObjectInputStream" seem (to me) to be inappropriate classes. Perhaps BufferedReader would be better?

Also, every time you open the file for writing, you are deleting any previous contents. Maybe the "RandomAccessFile" class will be more suitable?

Good Luck,
Avi.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!