Java Service to Generate a File on Windows Network

Hi

I am using the following Java code in the a Java service to create a file on a windows shared drive. But the file is not getting created. Can you tell me what might be the problem.

try {
BufferedWriter out = new BufferedWriter(new FileWriter(\\machine1/Folder1/m.txt));
out.write(“Hello”);
out.close();
} catch (IOException e) {
}

Change your code to this and it will show you what the specific error is. Ignore the URL wrappers–I couldn’t seem to get the forum software to not convert the filename string to an URL.

try {
BufferedWriter out = new BufferedWriter(new FileWriter(“\\machine1/Folder1/m.txt”));
out.write(“Hello”);
out.close();
} catch (IOException e) {
throw new ServiceException(e);
}

I am getting the following error

com.wm.app.b2b.server.ServiceException: java.io.FileNotFoundException: \machine1\Folder1\m.csv (Access is denied)

but i have given complete access to this folder.

I believe the user who starts the Integration Server needs access to that network folder.

Believe that as you are using "", this might be treated as an escape, try giving forward slash / or append the "" with another "".

like \\machine_name\Folder_name\File_name, this will be treated as \machine_name\folder_name\file_name.

Is the machine accessible from the IS??

HTH
Malhar

It would appear that the account used to access the sharepoint in fact does not have access. How is IS being run? At the command-line or as a service? If as a service, what account is being used? That account needs to have access to the share.

Given the error message, it would seem that the pathname is specified with the correct number of backslashes–if the backslashes were not escaped, the pathname in the error message would not have any backslashes.