public void Saveinfile(Vector v){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos= new DataOutputStream(baos);
try {
FileConnection fileConn =(FileConnection)Connector.open("file:///e:/bkp.txt", Connector.READ_WRITE);
if(!fileConn.exists()){
fileConn.create();}
else{
System.out.println("file already found");
}
dos = fileConn.openDataOutputStream();
Enumeration enumResults = v.elements();
while (enumResults.hasMoreElements()) {
dos.writeUTF("\n");
dos.writeUTF(String.valueOf(enumResults.nextElement()));
}
dos.close();
fileConn.close();
System.out.println("file saved");
} catch (IOException ex) {
ex.printStackTrace();
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos= new DataOutputStream(baos);
try {
FileConnection fileConn =(FileConnection)Connector.open("file:///e:/bkp.txt", Connector.READ_WRITE);
if(!fileConn.exists()){
fileConn.create();}
else{
System.out.println("file already found");
}
dos = fileConn.openDataOutputStream();
Enumeration enumResults = v.elements();
while (enumResults.hasMoreElements()) {
dos.writeUTF("\n");
dos.writeUTF(String.valueOf(enumResults.nextElement()));
}
dos.close();
fileConn.close();
System.out.println("file saved");
} catch (IOException ex) {
ex.printStackTrace();
}
}
No comments:
Post a Comment