Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. \machine01sharefldrresourceshydrant.jpg
  2.  
  3. String fileName = "hydrant.jpg";
  4. String dataPath = "//machine01/sharefldr/";
  5. String rscsDir = "resources";
  6. Path myFilePath = Paths.get(dataPath, rscsDir, fileName);
  7.  
  8. System.out.println("Testing path:" + myFilePath.toString());
  9. Boolean pExists = Files.exists(myFilePath);
  10. System.out.println("Path Exists:" + pExists);
  11. File dFile = myFilePath.toFile();
  12. System.out.println("dFile Exists:" + dFile.exists());
  13.  
  14. System.out.println("Testing UNC path:" + Paths.get(dataPath).toString());
  15. pExists = Files.exists( Paths.get(dataPath));
  16. System.out.println("Path Exists:" + pExists);
  17.  
  18. System.out.println("Testing mapped path:" + Paths.get("T:\").toString());
  19. pExists = Files.exists( Paths.get("T:\"));
  20. System.out.println("Path Exists:" + pExists);
  21.  
  22. try {
  23. Path file1 = Paths.get(dataPath, rscsDir, fileName);
  24. System.out.println("Getting image width of file: "+file1.toString());
  25. BufferedImage img1 = ImageIO.read(file1.toFile());
  26. System.out.println("Image width:"+img1.getWidth());
  27. }
  28. catch (IOException x) {
  29. System.out.println(x.getStackTrace());
  30. }
  31.  
  32. try {
  33. Path dir1 = Paths.get(dataPath, rscsDir);
  34. Path filePath = dir1.resolve(fileName);
  35. System.out.println("Getting image width of file2: "+filePath.toString());
  36. BufferedImage img1 = ImageIO.read(filePath.toFile());
  37. System.out.println("Image width:"+img1.getWidth());
  38. }
  39. catch (IOException x) {
  40. System.out.println(x.getStackTrace());
  41. }
  42.  
  43. Testing path:\machine01sharefldrresourceshydrant.jpg
  44. Path Exists:false
  45. dFile Exists:false
  46. Testing UNC path:\machine01sharefldr
  47. Path Exists:false
  48. Testing mapped path:T:
  49. Path Exists:false
  50. Getting image width of file: \machine01sharefldrresourceshydrant.jpg
  51. javax.imageio.IIOException: Can't read input file!
  52. + CategoryInfo : NotSpecified: (javax.imageio.I...ead input file!:String) [], RemoteException
  53. + FullyQualifiedErrorId : NativeCommandError
  54. + PSComputerName : TestTargetW10B
  55.  
  56. at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1308)
  57. NotSpecified: (:) [], RemoteException
  58. ...
  59. Getting image width of file2: \machine01sharefldrresourceshydrant.jpg
  60. javax.imageio.IIOException: Can't read input file!
  61. NotSpecified: (:) [], RemoteException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement