Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: create file in java

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile create file in java

    Hi all,


    Am trying to create the file that contains some attributes and parameters to that attributes . and also want to give permissions to modify , rename, and delete like this .please give me hints to do this task . i wrote a program to create the empty file .

    below is that
    import java.io.*;
    public class CreateFile
    {
    private static void doCreate()
    {
    File file = new File("NewFile1.txt");
    boolean success = false;
    try
    {
    success = file.createNewFile();
    } 
    catch (IOException e) 
    {
    e.printStackTrace();
    }
    if (success) 
    {
    System.out.println("File did not exist and was created.\n");
    } 
    else 
    {
    System.out.println("File already exists.\n");
    }
    }
    public static void main(String[] args)
    {
    doCreate();
    }
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: create file in java


  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: create file in java

    You've created the empty file... Now what? Please give some more information. An example would be nice.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Create a file specifying the size JAVA
    By Harbox in forum Java Theory & Questions
    Replies: 3
    Last Post: September 20th, 2012, 10:30 AM
  2. Replies: 10
    Last Post: January 12th, 2011, 05:48 AM
  3. How I can create those shapes with Java?
    By Learner in forum AWT / Java Swing
    Replies: 3
    Last Post: November 18th, 2010, 02:10 AM
  4. create a file
    By mos33 in forum Java Theory & Questions
    Replies: 4
    Last Post: December 4th, 2009, 02:21 PM
  5. How to create exe file
    By sirimalla in forum Java Theory & Questions
    Replies: 6
    Last Post: November 1st, 2009, 04:07 AM