hi dude,
i have got a solution for u .seems it OK.Just try out .
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args)
{
Properties prop = new Properties();
OutputStream out;
BufferedOutputStream br;
FileOutputStream fout;
try{
// fout = new FileOutputStream("a.txt");
//br = new BufferedOutputStream(out);
out = new FileOutputStream("a.txt");
prop.setProperty("name1","prajwal");
prop.setProperty("age","23");
prop.store(out,"emp");
}
catch(Exception e)
{}
}
}
the data will be written to harddisk.Like wise u can retreive the data back using load() .
hi dude
I m back again
Here is the exact stuff u needed
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args)
{
FileOutputStream fout;
ObjectOutputStream out ;
List list = new ArrayList();
list.add(new A());
list.add(new A());
list.add(new A());
try
{
fout = new FileOutputStream("a.txt");
out = new ObjectOutputStream(fout);
out.writeObject(list);
}
catch(Exception e)
{}
}
}
class A implements Serializable
{
public int a = 10;
}
HI, I am trying to save Vector object to a file which contains an image as one element.But i am not able to do that can anybody tell how to write the program.
i wrote the following program to do tha task but it's not working
can anybody tell what changes i have to make my program to work properly
my code as follows
import java.util.*;
import java.io.*;
import java.awt.*;
class ImageWrit implements Serializable
{
Image img;
public ImageWrit(){
img= Toolkit.getDefaultToolkit().getImage("a9.bmp");
}
}
class A{
public static void main(String s[])
{
FileOutputStream fout;
ObjectOutputStream out ;
Vector list = new Vector();
list.add(new ImageWrit());
try{
fout = new FileOutputStream("a.txt");
out = new ObjectOutputStream(fout);
out.writeObject(list);
System.out.println("object is saved");
}
catch(Exception e)
{
System.out.println("error");
}
}
}