Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading file from a share folder

Posted on 2001-06-28
4
Medium Priority
?
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

705 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