This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to write the output to the file.  RSS feed

 
Soumya Ranjan Mohanty
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;

public class FileIo {

public static void main(String args[]) {
try {
File f=new File("Testdir");
f.mkdir();
File subf=new File(f,"Subdir");
subf.mkdir();
File fsubf=new File(subf,"SsubDir");
fsubf.mkdir();
File newf= new File(f,"a.txt");
newf.createNewFile();
FileWriter fw=new FileWriter(newf);
BufferedWriter bw=new BufferedWriter(fw);
bw.write("SCJP");
bw.flush();
bw.close();

} catch(IOException e)
{
System.out.println(e);
}
}
}




Here is my Code , I am not able to Write into the file. Please Help me.
 
Jonas Isberg
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need you to help us help you by UseCodeTags and TellTheDetails.
What response from the program do you get, and what did you expect?
 
Soumya Ranjan Mohanty
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write using BufferedWriter in my file a.txt. As in the above example the word SCJP in my file a.txt under directory TestDir,
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall repeat:
Jonas Isberg wrote:TellTheDetails.
What response from the program do you get
 
Soumya Ranjan Mohanty
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get an output where nothing written to the file.. I want something to be written in the file a.txt
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


try this it will work.

regards
Raza.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!