Solved

writing to file .....(java.io.tmpdir)

Posted on 2004-10-01
4
196 Views
Last Modified: 2010-03-31
hi ...

i have a problem in writing the file to the temporary folder .....the file is not created ..if i give the path name by myself then the file is created .....
.
kindly anyone help me ....
Thanks in advance ....

MY CODING :

public void filewrite()
  {
 
        try {
           
                String temppath = new String(System.getProperty("java.io.tmpdir"));        
                String fileName = "temppath,outfile.txt";
                BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
           
            out.write("DB_CONNECTION =   ");        
            out.write(DBConnection.getText());
            out.write("; ");
            out.write(DBname.getText());
            out.write("; ");
            out.write(Username.getText());
            out.write("; ");
            out.write(password.getPassword());            
            out.close();

        } catch (IOException e) {

            System.out.println("IOException:"+e);
            e.printStackTrace();

        }
  }
0
Comment
Question by:sivaprakasam
  • 3
4 Comments
 
LVL 35

Expert Comment

by:girionis
Comment Utility
> String fileName = "temppath,outfile.txt";

Try to get rid of the comma and try again.

0
 
LVL 35

Accepted Solution

by:
girionis earned 55 total points
Comment Utility
> String fileName = "temppath,outfile.txt";

make it

String fileName = temppath + "outfile.txt";
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
:)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
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:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

772 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

16 Experts available now in Live!

Get 1:1 Help Now