1

So, I want to create a file in a folder on the desktop. But I don't want everyone who downloads the game to have to create that folder. Is there a way to do this? The did for the folder is:

/users/USER/desktop/MyFolder
Silvr Swrd
  • 59
  • 1
  • 1
  • 4
  • 1
    not sure, but to get the desktop folder, check this http://stackoverflow.com/questions/1080634/how-to-get-the-desktop-path-in-java and to create the directory itself, check http://docs.oracle.com/javase/7/docs/api/java/io/File.html#mkdir%28%29 – Leo Aug 03 '14 at 20:30

2 Answers2

1

I will direct you to the File Javadoc. It contains a few methods for creating new directories and files.

Example:

File file = new File("/users/USER/desktop/MyFolder");

if(!file.exists())
{
    file.makeDirs();
}
1

Don't worry this folder will be created automatically direct from the File(class) code which is the best option:check this out too...

import java.io.*;

File myFile=new File("/users/USER/desktop/MyFolder","something..");/*for instance "something.txt"**/ 
Devilhorn
  • 102
  • 1
  • 10