Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-28-2007, 03:30 AM   #1
In Runtime
 
eViLoNe's Avatar
 
Join Date: Aug 2005
Posts: 126
Default Java Address Book Project! Help needed!

Ok,

As the title states, I'm doing a java address book project. I have the GUI all setup, and ready, and also have the class setup to model a contact. The part I'm having trouble with is the actual opening of a binary file, and saving of a binary file to store the "vectors" in, which will hold the address book information.

If anyone here could shed some light on this for me, it would be greatly appreciated.

Thanks.
__________________

__________________
Intel Core 2 Quad Q6600 2.4GHz | Asustek P5K | 2x 1GB DDR2-800 Dual Channel | 3x Seagate 320GB 7200.10 SATA2 (16mb cache) | NVIDIA GeForce 8600 GT | 19 Philips 190S7FB LCD (1280x1024) | 600W Enermax
eViLoNe is offline   Reply With Quote
Old 06-20-2007, 01:58 PM   #2
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Java Address Book Project! Help needed!

ok, why don't you just use the jdbc odbc drivers and store the data in a database?
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 06-25-2007, 10:44 PM   #3
In Runtime
 
CGfreak102's Avatar
 
Join Date: Apr 2007
Posts: 475
Default Re: Java Address Book Project! Help needed!

heres somthing on how to read Binary Data from a binary file its a snipplet of code:



// Read binary data from a binary file.
// The name of the input file is
// passed as a command line argument.
//
//
// Adapted from exreaddata.java from
// "Just Java", P.van der Linden, ch.12
//
import java.io.*;

public class BinFileInput {
public static void main(String f[]) {
FileInputStream fis;
DataInputStream dis;
try {
fis = new FileInputStream(f[0]);
// Wrap with a DataInputStream to obtain
// its readInt() method.
dis = new DataInputStream( fis );
System.out.println( "file: " + f[0] );

int i;

while ( true ) {
i = dis.readInt();
System.out.println( "read: " + i );
}
} catch (EOFException eof)
{System.out.println( "EOF reached " ); }
catch (IOException ioe)
{System.out.println( "IO error: " + ioe );}

}

}
CGfreak102 is offline   Reply With Quote
Old 06-25-2007, 10:45 PM   #4
In Runtime
 
CGfreak102's Avatar
 
Join Date: Apr 2007
Posts: 475
Default Re: Java Address Book Project! Help needed!

And this is to Write Binary data to a binary file, again another snipplet:



// Write binary data to a binary file.
// The name of the output file is
// passed as a command line argument.
//
//
// Adapted from exwritedata.java from
// "Just Java", P.van der Linden, ch.12
//
import java.io.*;

public class BinFileOutput {
public static void main(String f[]) {
FileOutputStream fos;
DataOutputStream ds;
try {
fos = new FileOutputStream(f[0]);

// Wrap the FileOutputStream with a
// DataOutputStream to obtain its writeInt()
// method.
ds = new DataOutputStream( fos );

int a[] = {0,1,2,3,4,5,6,7,8,9};

for (int i=0; i<a.length; i++) {
ds.writeInt(a[i]);
}

} catch (IOException ioe) {
System.out.println( "IO error: " + ioe ); }
}
}
CGfreak102 is offline   Reply With Quote
Old 06-26-2007, 12:13 AM   #5
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default Re: Java Address Book Project! Help needed!

Wow, that's the best code I've seen you do man. What site did you get it from?

Watch the double posting though. We have an edit button. Just because you are my friend doesn't mean I"ll go easy on you .

As a heads up, if the file you are reading or writing to is not in the same folder, the "file name" you are reading or writing to must also include the path. IE C:\Documents and Settings\Bill_Joe_Bob\Java_stuff\email_addressbook .Java
__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 11:18 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0