Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-25-2007, 08:38 PM
Member
 
Join Date: May 2007
Posts: 4
Alpha is on a distinguished road
How to create a file
I need to create a file on disk and write to it. How can i do this with Java?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-25-2007, 09:31 PM
Member
 
Join Date: May 2007
Posts: 7
FaRuK is on a distinguished road
Hello Alpha,

You can use the following code to create a file:

Code:
try { File file = new File("filename"); // Create file if it does not exist boolean success = file.createNewFile(); if (success) { // File did not exist and was created } else { // File already exists } } catch (IOException e) { }
And for reading from or writing to the file, you can use following tips:

Java Tips - How to Read File in Java
Java Tips - How to write file in Java
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-25-2007, 09:44 PM
Member
 
Join Date: May 2007
Posts: 4
Alpha is on a distinguished road
Thanks Faruk, this is exactly what i want.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can java.io.File create a list of all files and folders. MattStone New To Java 20 12-17-2007 04:20 PM
Vector create Warren New To Java 3 11-19-2007 09:13 PM
Create a new variable mathias New To Java 1 08-07-2007 07:48 AM
How to create a xml file from oracle sql query boy22 XML 1 07-24-2007 01:15 AM
Create XML From XSD Jack XML 1 07-09-2007 01:56 AM


All times are GMT +3. The time now is 09:33 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org