Java Reference
In-Depth Information
public
public String getPasswordCypher () {
return
return passwordCypher ;
}
/** Save the clear text p/w in the object, it won't get serialized
* So we must save the encryption! Encryption not shown here.
*/
public
public void
void setPassword ( String s ) {
this
this . passwordClear = s ;
passwordCypher = encrypt ( passwordClear );
}
public
public String toString () {
return
return "MyData[" + userName + ",------]" ;
}
Because several methods are available for serializing, in Example 10-11 , I define an abstract
base class, called SerialDemoAbstractBase , which creates the data list and whose save()
method calls the abstract write() method to actually save the data.
Example 10-11. src/main/java/io/SerialDemoAbstractBase.c
/* C Program to create the random-access file for the RandomAccessFile example
* Ian F. Darwin, http://www.darwinsys.com/
*/
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <machine/endian.h>
const
const off_t
off_t OFFSET = 1234 ;
// off_t is a C "typedef", usually == long integer
const
const char
char * FILENAME = "random.dat" ;
const
const int
int MODE = 0644 ;
const
const char
char * MESSAGE = "Ye have sought, and ye have found!\r\n
\r\n" ;
int
int
main ( int
int argc , char
char ** argv ) {
int
int fd ;
int
int java_offset ;
iif (( fd = creat ( FILENAME , MODE )) < 0 ) {
perror ( FILENAME );
Search WWH ::




Custom Search