1 /*
2 * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
573 synchronized (closeLock) {
574 if (closed) {
575 return;
576 }
577 closed = true;
578 }
579 if (channel != null) {
580 /*
581 * Decrement FD use count associated with the channel. The FD use
582 * count is incremented whenever a new channel is obtained from
583 * this stream.
584 */
585 fd.decrementAndGetUseCount();
586 channel.close();
587 }
588
589 /*
590 * Decrement FD use count associated with this stream.
591 * The count got incremented by FileDescriptor during its construction.
592 */
593 fd.decrementAndGetUseCount();
594 close0();
595 }
596
597 //
598 // Some "reading/writing Java data types" methods stolen from
599 // DataInputStream and DataOutputStream.
600 //
601
602 /**
603 * Reads a <code>boolean</code> from this file. This method reads a
604 * single byte from the file, starting at the current file pointer.
605 * A value of <code>0</code> represents
606 * <code>false</code>. Any other value represents <code>true</code>.
607 * This method blocks until the byte is read, the end of the stream
608 * is detected, or an exception is thrown.
609 *
610 * @return the <code>boolean</code> value read.
611 * @exception EOFException if this file has reached the end.
612 * @exception IOException if an I/O error occurs.
613 */
614 public final boolean readBoolean() throws IOException {
615 int ch = this.read();
|
1 /*
2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
573 synchronized (closeLock) {
574 if (closed) {
575 return;
576 }
577 closed = true;
578 }
579 if (channel != null) {
580 /*
581 * Decrement FD use count associated with the channel. The FD use
582 * count is incremented whenever a new channel is obtained from
583 * this stream.
584 */
585 fd.decrementAndGetUseCount();
586 channel.close();
587 }
588
589 /*
590 * Decrement FD use count associated with this stream.
591 * The count got incremented by FileDescriptor during its construction.
592 */
593 int useCount = fd.decrementAndGetUseCount();
594
595 /*
596 * If FileDescriptor is still in use by another stream, we
597 * will not close it.
598 */
599 if (useCount <= 0) {
600 close0();
601 }
602 }
603
604 //
605 // Some "reading/writing Java data types" methods stolen from
606 // DataInputStream and DataOutputStream.
607 //
608
609 /**
610 * Reads a <code>boolean</code> from this file. This method reads a
611 * single byte from the file, starting at the current file pointer.
612 * A value of <code>0</code> represents
613 * <code>false</code>. Any other value represents <code>true</code>.
614 * This method blocks until the byte is read, the end of the stream
615 * is detected, or an exception is thrown.
616 *
617 * @return the <code>boolean</code> value read.
618 * @exception EOFException if this file has reached the end.
619 * @exception IOException if an I/O error occurs.
620 */
621 public final boolean readBoolean() throws IOException {
622 int ch = this.read();
|