Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading file from a share folder

Posted on 2001-06-28
4
Medium Priority
?
305 Views
Last Modified: 2010-05-19
Hi,
I am writing a java program which will read files from a share folder. Since it is a shared folders, users might be writing in to the file.

So before the program going to read the file, I want to check if the files is being accessed by some other process or what?

regards
vidyod
0
Comment
Question by:vidyod
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
jorj earned 400 total points
ID: 6237155
File.canRead(), File.canWrite(), File.exists() are the methods for you. The OS will check for you.
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6239118
Hi,

I don't think you need to do something special about that. Just open a file--if that's a wrong moment, IOException will be thrown. Calls to canRead() etc will not be very helpful--other process/user can open a file between your check and open attempt.

Regards,
Igor Bazarny,
Brainbench MVP for Java 1
www.brainbench.com
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8950883


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  points to jorj


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 8958186
Hmm, I believe canRead()/canWrite() check only file permissions, not sharing status. So, jorj comment don't answer this question IMO.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question