Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to Create Non-Read-Only Directories...

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I am trying to create a directory using JAVA in which the code will copy some files into. But the problem is the directory that is created is always read only and so am always getting an error while copying..



Could you please tell me how to create a non Read Only directory. I am using Java 1.4.2!
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you creating the directories?
Does the directory get created?
Do the parent directories exist? Do you or the users the application run as have permission to write to them?
Is the same user creating the directories and trying to copy?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the fragment of code....
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't answer my questions, so I can't give you much more advice than this: use mkdirs()
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you creating the directories?

As you may have already noticed that i am using mkdir() method.
Does the directory get created?

Yes the directories are getting created.
Do the parent directories exist? Do you or the users the application run as have permission to write to them?

I am using windows. The parent directories are getting created when the application is run. But when i check for the properties of the folders in windows i see that they are read only. That's the problem...
Is the same user creating the directories and trying to copy?

I am user and i am running the code in eclipse. So do dont think the code should have any user related violation!

I tried to post this yesterday, but the javaranch's server was down!
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somnath Mallick wrote:
I am using windows.


There's your problem. ALL directories in Windows are "read only". Funny thing is, you can create and write a file inside them.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well that gets rid of the access problem then! Thanks everyone!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic