• Post Reply Bookmark Topic Watch Topic
  • New Topic

creation of new directory inside an exisiting directory

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to write a file I/O code in which I need to create a subdirectory inside existing directories and then write a text file inside that new subdirectory created.



This is the code that I have written:



The issue is when I create directory ChatTranscripts manually, inside the path "D:/opt/jboss-4.0.3SP1/server/mercerhr/static_content/" the code runs fine but when I try to create it using the code above, it throws an error

java.io.FileNotFoundException: D:\opt\jboss-4.0.3SP1\server\mercerhr\static_content\ChatTranscripts\Mercer_Chat_1047835.txt (The system cannot find the path specified)

How can I ensure that the subdirectory ChatTranscripts gets created through Java code and hence the txt file inside it.
 
Paul Clapham
Sheriff
Posts: 21981
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To create a directory using Java code, use the mkdir() or mkdirs() method of the java.io.File class.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!