• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Access is denied i/o exception when trying to write a file.

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gang,
I am getting the following exception when I try to write a file to another machine on my network. I am using Windows 2K.
This code works fine when I copy a file from one directory to another on my own machine, but when I try to write to another machine on the network I get an "access is denied exception:
(Note: I overwrote the actuall IP address of the path in the exception message and the code with the text "IPAddress" for privacy)
The exception:
java.io.FileNotFoundException: \\IPAddress\d\tng2.0\config\ex.properties (Access is denied)
at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
The Code:
/**
* Copy file to store machines
*/
public void copyFile(String _filePath) throws IOException {
File inputFile = new File(_filePath);
File outputFile = new File("\\\\IPAddress\\c\\tng2.0\\config\\exit41.properties");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
}
Any info would be greatly appreciated to help me get past this exception!
Thanks very much,
Kim
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, me again,
I just tried adding this line to my code:
FilePermission permission = new FilePermission("\\\\IPAddress\\C\\tng2.0\\config\\*", "read,write");
Still getting the same Access is Denied exception.
Think I am on the right path with the FilePermission object?
Kim
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic