Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \machine01sharefldrresourceshydrant.jpg
- String fileName = "hydrant.jpg";
- String dataPath = "//machine01/sharefldr/";
- String rscsDir = "resources";
- Path myFilePath = Paths.get(dataPath, rscsDir, fileName);
- System.out.println("Testing path:" + myFilePath.toString());
- Boolean pExists = Files.exists(myFilePath);
- System.out.println("Path Exists:" + pExists);
- File dFile = myFilePath.toFile();
- System.out.println("dFile Exists:" + dFile.exists());
- System.out.println("Testing UNC path:" + Paths.get(dataPath).toString());
- pExists = Files.exists( Paths.get(dataPath));
- System.out.println("Path Exists:" + pExists);
- System.out.println("Testing mapped path:" + Paths.get("T:\").toString());
- pExists = Files.exists( Paths.get("T:\"));
- System.out.println("Path Exists:" + pExists);
- try {
- Path file1 = Paths.get(dataPath, rscsDir, fileName);
- System.out.println("Getting image width of file: "+file1.toString());
- BufferedImage img1 = ImageIO.read(file1.toFile());
- System.out.println("Image width:"+img1.getWidth());
- }
- catch (IOException x) {
- System.out.println(x.getStackTrace());
- }
- try {
- Path dir1 = Paths.get(dataPath, rscsDir);
- Path filePath = dir1.resolve(fileName);
- System.out.println("Getting image width of file2: "+filePath.toString());
- BufferedImage img1 = ImageIO.read(filePath.toFile());
- System.out.println("Image width:"+img1.getWidth());
- }
- catch (IOException x) {
- System.out.println(x.getStackTrace());
- }
- Testing path:\machine01sharefldrresourceshydrant.jpg
- Path Exists:false
- dFile Exists:false
- Testing UNC path:\machine01sharefldr
- Path Exists:false
- Testing mapped path:T:
- Path Exists:false
- Getting image width of file: \machine01sharefldrresourceshydrant.jpg
- javax.imageio.IIOException: Can't read input file!
- + CategoryInfo : NotSpecified: (javax.imageio.I...ead input file!:String) [], RemoteException
- + FullyQualifiedErrorId : NativeCommandError
- + PSComputerName : TestTargetW10B
- at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1308)
- NotSpecified: (:) [], RemoteException
- ...
- Getting image width of file2: \machine01sharefldrresourceshydrant.jpg
- javax.imageio.IIOException: Can't read input file!
- NotSpecified: (:) [], RemoteException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement