2012-08-15 4 views
0

Java에서 FileLock을 사용하여 파일을 잠그지 만, 이제는 파일을 읽고 쓸 수 없습니다. 나는 무엇을해야합니까? 나는 그것을 발견 할 때Java에서 잠긴 파일을 읽거나 쓸 수 없습니다.

// Gets a readable and writable channel to your file. 
FileChannel channel = new RandomAccessFile(yourFile, "rw").getChannel(); 

// Allows you to read from the file. 
InputStream in = Channels.getInputStream(channel); 

// Allows you to write to the file. 
OutputStream out = Channels.getOutputStream(channel); 

// Lock the file here as you see fit to prevent concurrency issues. 
// As a concrete example, you could attempt to lock the file using "channel.tryLock()" 
... 

나는 매우 실망이 문제를 발견, 그래서 내가 거라 생각 :이 문제에 많은 잠재적 인 해결책이있을 수 있지만

+1

"할 수 없음"을 정의하십시오. 대신 무엇이 발생합니까? – EJP

답변

2

, 나는 아주 능숙하게 다음 작품 것으로 나타났습니다 내 솔루션을 필요로하는 다른 사람들과 공유하십시오.

관련 문제