This discussion is archived
1 Reply Latest reply: Jun 7, 2007 2:10 PM by 807606 RSS

How to Create File in another folder

807606 Newbie
Currently Being Moderated
hi,
I need to create a RandomAccessFile in Folder and that Folder was also created here if self only, so How it do this in a program.
tname="xyz";
String fname=tname+".xml";
file = new File(fname);
File dir=new File(tname);
String path=dir.getAbsolutePath();
System.out.println(path);
if(dir.exists()==false)
dir.mkdirs();

I try to create xyz.xml file in xyz(folder name) itself, how can if be

Thanking you,
RaviVarma.K
  • 1. Re: How to Create File in another folder
    807606 Newbie
    Currently Being Moderated
    I'm not sure what you are trying to do but you seem to need
            File f = new File("the path of the file you want to create");
            f.getParentFile().mkdirs();
    No need to make the mkdirs() conditional since it will only make the directories if they don't exist.