file-exists

Check whether the path exists on server or not in Java

岁酱吖の 提交于 2021-02-09 11:52:10
问题 I am creating a Java program in which I am uploading file to server on a particular path. I am using jSch for sftp . So, before uploading the file, I want to check if the given directory exists on server or not. if(path exists) //upload file to the location else //create the directory and then upload the file. How do I check the path exists or not? Note: I am executing the code on a client that will check for the existence of a remote directory on a server. So please don't suggest File.exists

File.Exists acts differently when access is denied to the file vs denied to the dir

℡╲_俬逩灬. 提交于 2020-08-19 07:45:05
问题 Based on the MSDN documentation of File.Exists , the File.Exists method should return false on any error, including the caller not having access to read the file. I would expect it to return false both when the file is set to FullControl denied to the user and FullControl denied to the user to the directory the file lives in. What I'm seeing is when the user has access to the directory, but not the file, File.Exists returns true ; however, if the user has no access to the directory, File

Check if a directory contains a file with a given extension

萝らか妹 提交于 2020-03-13 04:52:06
问题 I need to check the current directory and see if a file with an extension exists. My setup will (usually) only have one file with this extension. I need to check if that file exists, and if it does, run a command. However, it runs the else multiple times because there are multiple files with alternate extensions. It must only run the else if the file does not exist, not once for every other file. My code sample is below. The directory is structured like so: dir________________________________

Check if a directory contains a file with a given extension

…衆ロ難τιáo~ 提交于 2020-03-13 04:51:09
问题 I need to check the current directory and see if a file with an extension exists. My setup will (usually) only have one file with this extension. I need to check if that file exists, and if it does, run a command. However, it runs the else multiple times because there are multiple files with alternate extensions. It must only run the else if the file does not exist, not once for every other file. My code sample is below. The directory is structured like so: dir________________________________

Check if a directory contains a file with a given extension

China☆狼群 提交于 2020-03-13 04:51:07
问题 I need to check the current directory and see if a file with an extension exists. My setup will (usually) only have one file with this extension. I need to check if that file exists, and if it does, run a command. However, it runs the else multiple times because there are multiple files with alternate extensions. It must only run the else if the file does not exist, not once for every other file. My code sample is below. The directory is structured like so: dir________________________________

How do I activate a Maven profile if a file does NOT exist?

安稳与你 提交于 2020-02-25 10:16:05
问题 I’m using Maven 3.2.3. How do I activate a profile if a file does NOT exist on the file system? I have tried the below, but discovered that the <not> syntax isn’t supported: <profile> <id>create-test-mysql-props-file</id> <activation> <file> <not><exists>${basedir}/src/main/myfile</exists></not> </file> </activation> <build> <plugins> <!-- Generate mysql datasource properties --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha

Fastest way to redirect missing image files

烂漫一生 提交于 2020-01-07 04:12:25
问题 I have an on-the-fly thumbnailing system and am trying to find the best way to make sure it's as fast as possible when serving up images. Here is the current flow: User requests thumbnail thumbnails/this-is-the-image-name.gif?w=200&h=100&c=true htaccess file uses modrewrite to send requests from this folder to a PHP file PHP file checks file_exists() for the requested image based on the query string values If it does: header('content-type: image/jpeg'); echo file_get_contents($file_check_path

node.js - check if file exists before creating temp file

守給你的承諾、 提交于 2020-01-05 09:33:55
问题 I want to create a temporary file/directory in node.js. To do this, I'm attempting a simple algorithm: Generate a file name based on pid, time, and random chars Check if file exists if yes: return to step 1 and repeat if not: create the file and return it Here's the problem: The node.js documentation for fs.exists explicitly states that fs.exists should not be used, and instead one should just use fs.open and catch a potential error: http://nodejs.org/docs/latest/api/fs.html#fs_fs_exists_path

checking if file exists in a specific directory

不问归期 提交于 2020-01-01 07:35:21
问题 I am trying to check for a specific file in a given directory. I don't want the code but I want to fix the one I have. The only difference in this question, is that I look for files with an extension .MOD . I have the code ready:- public static int checkExists(String directory, String file) { File dir = new File(directory); File[] dir_contents = dir.listFiles(); String temp = file + ".MOD"; boolean check = new File(temp).exists(); System.out.println("Check"+check); // -->always says false for