• Post Reply Bookmark Topic Watch Topic
  • New Topic

Putting file in directory  RSS feed

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to create directory in a server . But I am unable to put any newly created files into the dir even though i specify the full path. Below is my code. It just create files with the name of the path attached whereas it is the path of the dir I want it to create to. The funny thing is i use the code to create on C drive on standalone pc, it works. Please advise.
String subDirPath = dateToday();
File myFile = new File(subDirPath);
if(!myFile.exists())
myFile.mkdir();
String hostpath = "hostname\\home\\db\\Rpt\\" + subDirPath;

/**** Write to the file ****/
String path3 = "AllRpt" + ".txt";
File output3 = new File(path3);

FileWriter out3 = new FileWriter(output3);
out3.write(successtext3);
out3.close();
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if I understand what you're trying to do, or what's happening.
You've got code to create a file "AllRpt.txt". It looks like this will create a new file in the current working directory (wherever you're executing the program from) rather than putting it in the subdirectory. If you want to put this file in the subdirectory, you have to specify that this subdir is part of the path:

If that doesn't solve your problem, we probably need more information. What's "hostname" anyway? Do you really say "hostname", or do you replace it with something more specific? What, exactly?
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. I figure out my mistake finally
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!