|
| ||||||||||
| Tags: file, file system, multithread, process, source code, thread |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Program to see file used by another process
I would like to test if a file is used by another process. I try to do the following code, have a look at it Code: canRead() and canWrite() |
|
#2
| |||
| |||
| Re: Program to see file used by another process
Hello, With the File class, you can not. What you can do is create a FileInputStream or FileOutputStream, and do a close (). I recommend you to use a try / catch around, and if an exception is thrown, it's that close () failed, so your file is used for reading or writing. I think you should first have any idea of the java.io package that contains all the input and the output classes which are used in the I/O programs in java. So, I strongly recommend you to first learn or take a look at the java.io package. |
|
#3
| |||
| |||
| Re: Program to see file used by another process
Hello, Attention because it can be dangerous. Even if you write anything in it, simply open a FileOutputStream erase the contents of the file. In addition, a file can be used by multiple programs simultaneously. So you will not get necessarily exceptional. While using the java.io package that is the classes in the package first understand what you are trying to do with the program of the file which you are dealing with, if you miss something in the program then it can be dangerous for the file, that is you can even loose the file. |
|
#4
| |||
| |||
| Re: Program to see file used by another process
Hello, Even I am searching for a similar program, I have a treatment that launches executable via Process.exec () and this treatment aims to repatriate me a csv file from the machine that starts the process and creates the csv file into a new file whose name is the date of launch given parameter. But the whole thing is not quite working for me. If you have any solution for this then please help me with this. Thanks in advance. |
|
#5
| |||
| |||
| Re: Program to see file used by another process
Hello, This is my updated code please have a look at it and if you find any problems in the code then correct me with the same Here is my code: Code: do {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.getMessage();
}
try {
f = new File(fluse);
flinstr = new flinstr(fluse);
} catch (FileNotFoundException e1) {
e1.getMessage();
comments.add("File"+ + fluse"Was not loaded => f not found problem");
}
} while (! f.canRead()); |
|
#6
| |||
| |||
| Re: Program to see file used by another process
Hello, Do not know exactly that this is what you want, but have a look at the following code, may help you Code: try {
Process = runtime.getRuntime().exec(shellCommand);
p.waitfor();
} catch (IOException ioe) {
ext.getIOException(ioe);
comt.add("The file was not executed APPTMP.csv => execution problem");
}catch (InterruptedException e) {
comt.add("there is a problem of p execution");
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Program to see file used by another process" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Configuration process starts every time I open an Office program | Manik | MS Office Support | 1 | 04-02-2013 10:21 AM |
| Learning Batch file to open a program or a file | Ikshana | Windows Software | 3 | 04-04-2011 07:24 PM |
| How do I tell what process owns a file? | JamesB | Operating Systems | 3 | 27-07-2009 08:45 PM |
| How to conclude Which Windows Process is Using a File | Jaisudha | Operating Systems | 3 | 06-07-2009 11:59 AM |
| How to terminate Process and Delete the Source Program with Ultimate Process Killer | jackalz | Tips & Tweaks | 1 | 26-03-2009 06:31 PM |