473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Java - Writing to File Help Needed!

Hey,
Im working on a programme and need it to write to file. I put in a file writer it seems to run ok, creates the txt file but doesnt write any data. Heres the code:

private void requestJButtonActionPerformed (ActionEvent event)
{

Writer fw = null;

try
{
//fw = new FileWriter( "customer.txt" );
final FileWriter outputFile = new FileWriter("customer.txt");
final BufferedWriter outputBuffer = new BufferedWriter(outputFile);
final PrintWriter printstream = new PrintWriter(outputBuffer);
fw.write( phoneJTextField + "," + postcodeJTextField );
}
catch ( IOException e ) {
System.err.println( "Cannot write to file" );
}

finally {
if ( fw != null )
try { fw.close(); } catch ( IOException e ) { }
}


}

any ideas then please help!

Thanks

Nicole
Dec 6 '07 #1
2 1229
dmjpro
2,476 2GB
Hey,
Im working on a programme and need it to write to file. I put in a file writer it seems to run ok, creates the txt file but doesnt write any data. Heres the code:

private void requestJButtonActionPerformed (ActionEvent event)
{

Writer fw = null;

try
{
//fw = new FileWriter( "customer.txt" );
final FileWriter outputFile = new FileWriter("customer.txt");
final BufferedWriter outputBuffer = new BufferedWriter(outputFile);
final PrintWriter printstream = new PrintWriter(outputBuffer);
fw.write( phoneJTextField + "," + postcodeJTextField );
}
catch ( IOException e ) {
System.err.println( "Cannot write to file" );
}

finally {
if ( fw != null )
try { fw.close(); } catch ( IOException e ) { }
}


}

any ideas then please help!

Thanks

Nicole
Welcome to TSDN!
But fw is stil null.

Debasis Jana
Dec 6 '07 #2
r035198x
13,262 8TB
Hey,
Im working on a programme and need it to write to file. I put in a file writer it seems to run ok, creates the txt file but doesnt write any data. Heres the code:

private void requestJButtonActionPerformed (ActionEvent event)
{

Writer fw = null;

try
{
//fw = new FileWriter( "customer.txt" );
final FileWriter outputFile = new FileWriter("customer.txt");
final BufferedWriter outputBuffer = new BufferedWriter(outputFile);
final PrintWriter printstream = new PrintWriter(outputBuffer);
fw.write( phoneJTextField + "," + postcodeJTextField );
}
catch ( IOException e ) {
System.err.println( "Cannot write to file" );
}

finally {
if ( fw != null )
try { fw.close(); } catch ( IOException e ) { }
}


}

any ideas then please help!

Thanks

Nicole

How to read and write text files
Dec 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: beejisbrigit | last post by:
Hi there, I was wondering if anyone had experience with File I/O in Java vs. C++ using mmap(), and knew if the performance was better in one that the other, or more or less negligible. My...
29
by: s0suk3 | last post by:
Hello, I was hoping to get some opinions on a subject. I've been programming Python for almost two years now. Recently I learned Perl, but frankly I'm not very comfortable with it. Now I want to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.