Forums Register Login

how do I create a new File in order to write info

+Pie Number of slices to send: Send
How do I write to a file (ie: a non existing file) for eg. the user will input todays total sales thus a new file will need to be created with todays date; prior to java 1.2 since I cannot use
such methods as createNewFile()
Thank u for your help.
+Pie Number of slices to send: Send
hi there,
you probably will have to use the following lines of code,i guess
--------
String today = new Date();
FileOutputStream ostream = new FileOutputStream("today");
ObjectOutputStream p = new ObjectOutputStream(ostream);
p.writeObject(your figure);
.
.
--------
i hope this is what you are expecting
+Pie Number of slices to send: Send
here u go:
import java.io.*;
import java.util.*;
public class update
{
public static void main(String args[]) throws IOException
{ File f=new File("c:/update.txt");
String today=(new Date()).toString();
FileWriter fw=new FileWriter(f);
fw.write(today);
fw.close();
}
}
p.s. the Date() constructor is i suppose deprecated but i dont know the new version.

[This message has been edited by guy ranch (edited May 19, 2001).]
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 858 times.
Similar Threads
Getting yesterday's date ......
How to insert date values to database using java swings
calculate todays date minus last one year in java
Question on Creation of a Date Object
Conditionally copying parts of a file using Ant
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:44:30.