Solved

Writing a string to a file object

Posted on 2007-11-14
1
192 Views
Last Modified: 2010-03-30
I have a String. as input. I need to write it to a file object I am finding bufferinputstream ...I need the file object as the program has to return a file object

public HashMap generateXML(String str)
    {
        File f = new File("Product.xml");
        BufferedInputStream bis=null;
        BufferedOutputStream bos = null;
       
0
Comment
Question by:rmvprasad
1 Comment
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 125 total points
ID: 20284690
try this..

String example = "<a>this is a test</a>";
File myFile = new File("Product.xml");
FileWriter fw = new FileWriter(myFile);
fw.write(example);
fw.flush();
fw.close();

R.K
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now