Advertisement
Guest User

Untitled

a guest
Sep 8th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. // generando el nombre y extensión, Naming the file
  2. String fileUri = FILE_URI;
  3. String nameDomain = NAME_DOMAIN;
  4. String fileName= START_NAME_FILE +"_"+formatCalToday+ FILE_EXTENSION;
  5. String credentialsUserName = getConfigurationValue(delegator, "inventoryManagementPharmacyApp", "inventoryGeneral", "pathRouteConfigurableUserforUsername");
  6. String credentialsPassword = getConfigurationValue(delegator, "inventoryManagementPharmacyApp", "inventoryGeneral", "pathRouteConfigurableUserforPassword");
  7. String pathRuta = getConfigurationValue(delegator, "inventoryManagementPharmacyApp", "inventoryGeneral", "pathRouteConfigurableUserLevel");
  8.  
  9. final String user = credentialsUserName + ":" + credentialsPassword;
  10. final NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
  11. String path = fileUri+pathRuta+fileName;
  12. final SmbFile sFile = new SmbFile(path, auth);
  13. final SmbFileOutputStream salida2 = new SmbFileOutputStream(sFile);
  14.  
  15. fileUri = "smb:"
  16. fileName = "archivo.txt"
  17. credentialUserName = "username" de la red compartida
  18. credentialPassword = "password" de la red compartida
  19. pathRuta= \ipInforme Ventas
  20. path = smb:\ipInforme Ventas archivo.txt
  21.  
  22. fileUri + pathRuta + fileName;
  23.  
  24. String commandConnect = "cmd /c net use \\" + ip
  25. + "\ipc$ /user:" + credentialsUserName + " " + credentialsPassword;
  26.  
  27. //He expects the process to finalize
  28. try {
  29. Process process = Runtime.getRuntime().exec(commandConnect);
  30. int exitCode = process.waitFor();
  31. if (exitCode != 0) {
  32. throw new IOException("Command exited with " + exitCode);
  33. }
  34. } catch (Exception ex) {
  35. ex.getMessage();
  36. }
  37.  
  38. String commandDisconnect = "cmd /c net use \\" + ip
  39. + "\ipc$ /d";
  40. //He expects the process to finalize
  41. try {
  42. Process process = Runtime.getRuntime().exec(commandDisconnect);
  43. int exitCode = process.waitFor();
  44. if (exitCode != 0) {
  45. throw new IOException("Command exited with " + exitCode);
  46. }
  47. } catch (Exception ex) {
  48. ex.getMessage();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement