1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
10 package test
.IceUtil
.fileLock
;
12 import java
.io
.BufferedReader
;
13 import java
.io
.InputStreamReader
;
16 import java
.io
.RandomAccessFile
;
17 import java
.io
.EOFException
;
18 import java
.io
.UTFDataFormatException
;
19 import java
.io
.IOException
;
22 public class ClientFail
29 throw new RuntimeException();
36 IceUtilInternal
.FileLock lock
= null;
39 lock
= new IceUtilInternal
.FileLock("file.lock");
42 catch(IceUtil
.FileLockException ex
)
44 System
.out
.println("File lock not acquired.");
46 // Try to read the pid of the lock owner from the lock file, in Windows
47 // we don't write pid to lock files.
49 if(!System
.getProperty("os.name").startsWith("Windows"))
54 RandomAccessFile file
= new RandomAccessFile(new File("file.lock"), "r");
57 catch(EOFException eofEx
)
59 System
.out
.println("exception:\n" + eofEx
.toString());
62 catch(UTFDataFormatException utfEx
)
64 System
.out
.println("exception:\n" + utfEx
.toString());
67 catch(IOException ioEx
)
69 System
.out
.println("exception:\n" + ioEx
.toString());
77 System
.out
.println("Lock owned by: " + pid
);