-
January 10th, 2001, 05:32 AM
#1
how do i write data to text file
How can i write the string value to a text file ?
I try to use FileWriter but it return me error.
Please help.
-
January 10th, 2001, 06:05 AM
#2
Re: how do i write data to text file
Hi,
What does the error say?
You can write a string value to a text file like this:
FileWriter writer = new FileWriter("test.txt");
writer.write("this is a test file");
writer.close();
If you try this, what error do you get?
Regards,
Geert Arys
-
January 10th, 2001, 08:42 PM
#3
Re: how do i write data to text file
Error program below.. pls help ..
import java.io.*;
public class FileWriterTest
{
FileWriter famex = new FileWriter("amex.txt");
famex.write("Success write into text file");
famex.close();
}
********** Error code ************
FileWriterTest.java6: Type Expected
famex.write("Success write into text file");
^
********** End Error code ************
-
January 10th, 2001, 10:07 PM
#4
Re: how do i write data to text file
> public class FileWriterTest
> {
> FileWriter famex = new FileWriter("amex.txt");
> famex.write("Success write into text file");
> famex.close();
> }
Where is the function ???? Shouldnt those 3 lines be inside a function ????
-
January 11th, 2001, 01:30 AM
#5
Re: how do i write data to text file
this the full code .. what is wrong ?
***************
import java.io.FileWriter;
class FileWriterTest
{
public static void main(String[] args)
{
FileWriter fwriter = new FileWriter("Amex.txt");
fwriter.write("testing");
fwriter.close();;
}
}
***************
-
January 11th, 2001, 02:26 AM
#6
Re: how do i write data to text file
Hi
Try this. It works. You had not catched the exception..
import java.io.FileWriter;
class FileWriterTest
{
public static void main(String[] args)
{
try
{
FileWriter fwriter = new FileWriter("Amex.txt");
fwriter.write("testing");
fwriter.close();;
}
catch(Exception e){}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|