Link to home
Start Free TrialLog in
Avatar of cutie_smily
cutie_smily

asked on

Urgent! While creating a file on remote machine . Access denied message. Remote machine is Windows

While creating a file getting access denied message. Any clue how to change the permission so ..everybody can create and update file contents. On the remote machine folder permissions look okay.

Here is the code i am using
public String testService(String str){
            File file = new File("c:\\user_uploads\\anonymous\\test.txt");
            try {
                  file.createNewFile();
                  return "created";
            } catch (Exception e) {
                  // TODO Auto-generated catch block
                  System.out.println("An exception Occured in testService");
                  return e.getMessage();
            }
      }
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cutie_smily
cutie_smily

ASKER

file.createNewFile();


This will create a file on my local machine. When i excute on the remote machine ..it doesn't access denied meessage.
How to chaneg the permissions
Thanks
check the os that the user has required permissions
and as I mentioned above check for security manager

If i do write below code its creating and writing

BufferedWriter outfile = new BufferedWriter(new FileWriter(file));
                  outfile.write("a xml string");
                  outfile.close();

                  System.out.println("File Writing");
                  return "created";


but i write file.createNewFile() //Access denied message.

Let me know if there is anyother way to create.

Permissions are checked on folder options they are okay and the security manger too
you sure file is not a directory?

System.out.println("Directory "+file.isDirectory());
System.out.println("Exists "+file.exists());

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)