forked from bjmashibing/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuffer.html
More file actions
930 lines (866 loc) · 36.6 KB
/
Buffer.html
File metadata and controls
930 lines (866 loc) · 36.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>Buffer (Java SE 12 & JDK 12 )</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="java.nio.Buffer class">
<meta name="keywords" content="capacity()">
<meta name="keywords" content="position()">
<meta name="keywords" content="limit()">
<meta name="keywords" content="mark()">
<meta name="keywords" content="reset()">
<meta name="keywords" content="clear()">
<meta name="keywords" content="flip()">
<meta name="keywords" content="rewind()">
<meta name="keywords" content="remaining()">
<meta name="keywords" content="hasRemaining()">
<meta name="keywords" content="isReadOnly()">
<meta name="keywords" content="hasArray()">
<meta name="keywords" content="array()">
<meta name="keywords" content="arrayOffset()">
<meta name="keywords" content="isDirect()">
<meta name="keywords" content="slice()">
<meta name="keywords" content="duplicate()">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
<script type="text/javascript" src="../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Buffer (Java SE 12 & JDK 12 )";
}
}
catch(err) {
}
//-->
var data = {"i0":6,"i1":6,"i2":10,"i3":10,"i4":6,"i5":10,"i6":6,"i7":10,"i8":6,"i9":6,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../index.html">Overview</a></li>
<li><a href="../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Buffer.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="moduleLabelInType">Module</span> <a href="../../module-summary.html">java.base</a></div>
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">java.nio</a></div>
<h2 title="Class Buffer" class="title">Class Buffer</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="../lang/Object.html" title="class in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>java.nio.Buffer</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="ByteBuffer.html" title="class in java.nio">ByteBuffer</a></code>, <code><a href="CharBuffer.html" title="class in java.nio">CharBuffer</a></code>, <code><a href="DoubleBuffer.html" title="class in java.nio">DoubleBuffer</a></code>, <code><a href="FloatBuffer.html" title="class in java.nio">FloatBuffer</a></code>, <code><a href="IntBuffer.html" title="class in java.nio">IntBuffer</a></code>, <code><a href="LongBuffer.html" title="class in java.nio">LongBuffer</a></code>, <code><a href="ShortBuffer.html" title="class in java.nio">ShortBuffer</a></code></dd>
</dl>
<hr>
<pre>public abstract class <span class="typeNameLabel">Buffer</span>
extends <a href="../lang/Object.html" title="class in java.lang">Object</a></pre>
<div class="block">A container for data of a specific primitive type.
<p> A buffer is a linear, finite sequence of elements of a specific
primitive type. Aside from its content, the essential properties of a
buffer are its capacity, limit, and position: </p>
<blockquote>
<p> A buffer's <i>capacity</i> is the number of elements it contains. The
capacity of a buffer is never negative and never changes. </p>
<p> A buffer's <i>limit</i> is the index of the first element that should
not be read or written. A buffer's limit is never negative and is never
greater than its capacity. </p>
<p> A buffer's <i>position</i> is the index of the next element to be
read or written. A buffer's position is never negative and is never
greater than its limit. </p>
</blockquote>
<p> There is one subclass of this class for each non-boolean primitive type.
<h2> Transferring data </h2>
<p> Each subclass of this class defines two categories of <i>get</i> and
<i>put</i> operations: </p>
<blockquote>
<p> <i>Relative</i> operations read or write one or more elements starting
at the current position and then increment the position by the number of
elements transferred. If the requested transfer exceeds the limit then a
relative <i>get</i> operation throws a <a href="BufferUnderflowException.html" title="class in java.nio"><code>BufferUnderflowException</code></a>
and a relative <i>put</i> operation throws a <a href="BufferOverflowException.html" title="class in java.nio"><code>BufferOverflowException</code></a>; in either case, no data is transferred. </p>
<p> <i>Absolute</i> operations take an explicit element index and do not
affect the position. Absolute <i>get</i> and <i>put</i> operations throw
an <a href="../lang/IndexOutOfBoundsException.html" title="class in java.lang"><code>IndexOutOfBoundsException</code></a> if the index argument exceeds the
limit. </p>
</blockquote>
<p> Data may also, of course, be transferred in to or out of a buffer by the
I/O operations of an appropriate channel, which are always relative to the
current position.
<h2> Marking and resetting </h2>
<p> A buffer's <i>mark</i> is the index to which its position will be reset
when the <a href="#reset()"><code>reset</code></a> method is invoked. The mark is not always
defined, but when it is defined it is never negative and is never greater
than the position. If the mark is defined then it is discarded when the
position or the limit is adjusted to a value smaller than the mark. If the
mark is not defined then invoking the <a href="#reset()"><code>reset</code></a> method causes an
<a href="InvalidMarkException.html" title="class in java.nio"><code>InvalidMarkException</code></a> to be thrown.
<h2> Invariants </h2>
<p> The following invariant holds for the mark, position, limit, and
capacity values:
<blockquote>
<code>0</code> <code><=</code>
<i>mark</i> <code><=</code>
<i>position</i> <code><=</code>
<i>limit</i> <code><=</code>
<i>capacity</i>
</blockquote>
<p> A newly-created buffer always has a position of zero and a mark that is
undefined. The initial limit may be zero, or it may be some other value
that depends upon the type of the buffer and the manner in which it is
constructed. Each element of a newly-allocated buffer is initialized
to zero.
<h2> Additional operations </h2>
<p> In addition to methods for accessing the position, limit, and capacity
values and for marking and resetting, this class also defines the following
operations upon buffers:
<ul>
<li><p> <a href="#clear()"><code>clear()</code></a> makes a buffer ready for a new sequence of
channel-read or relative <i>put</i> operations: It sets the limit to the
capacity and the position to zero. </p></li>
<li><p> <a href="#flip()"><code>flip()</code></a> makes a buffer ready for a new sequence of
channel-write or relative <i>get</i> operations: It sets the limit to the
current position and then sets the position to zero. </p></li>
<li><p> <a href="#rewind()"><code>rewind()</code></a> makes a buffer ready for re-reading the data that
it already contains: It leaves the limit unchanged and sets the position
to zero. </p></li>
<li><p> <a href="#slice()"><code>slice()</code></a> creates a subsequence of a buffer: It leaves the
limit and the position unchanged. </p></li>
<li><p> <a href="#duplicate()"><code>duplicate()</code></a> creates a shallow copy of a buffer: It leaves
the limit and the position unchanged. </p></li>
</ul>
<h2> Read-only buffers </h2>
<p> Every buffer is readable, but not every buffer is writable. The
mutation methods of each buffer class are specified as <i>optional
operations</i> that will throw a <a href="ReadOnlyBufferException.html" title="class in java.nio"><code>ReadOnlyBufferException</code></a> when
invoked upon a read-only buffer. A read-only buffer does not allow its
content to be changed, but its mark, position, and limit values are mutable.
Whether or not a buffer is read-only may be determined by invoking its
<a href="#isReadOnly()"><code>isReadOnly</code></a> method.
<h2> Thread safety </h2>
<p> Buffers are not safe for use by multiple concurrent threads. If a
buffer is to be used by more than one thread then access to the buffer
should be controlled by appropriate synchronization.
<h2> Invocation chaining </h2>
<p> Methods in this class that do not otherwise have a value to return are
specified to return the buffer upon which they are invoked. This allows
method invocations to be chained; for example, the sequence of statements
<blockquote><pre>
b.flip();
b.position(23);
b.limit(42);</pre></blockquote>
can be replaced by the single, more compact statement
<blockquote><pre>
b.flip().position(23).limit(42);</pre></blockquote></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.4</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t3" class="tableTab" onclick="show(4);">Abstract Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>abstract <a href="../lang/Object.html" title="class in java.lang">Object</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#array()">array</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the array that backs this
buffer <i>(optional operation)</i>.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code>abstract int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#arrayOffset()">arrayOffset</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the offset within this buffer's backing array of the first
element of the buffer <i>(optional operation)</i>.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#capacity()">capacity</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns this buffer's capacity.</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#clear()">clear</a></span>()</code></th>
<td class="colLast">
<div class="block">Clears this buffer.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>abstract <a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#duplicate()">duplicate</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a new buffer that shares this buffer's content.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#flip()">flip</a></span>()</code></th>
<td class="colLast">
<div class="block">Flips this buffer.</div>
</td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code>abstract boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hasArray()">hasArray</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether or not this buffer is backed by an accessible
array.</div>
</td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hasRemaining()">hasRemaining</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether there are any elements between the current position and
the limit.</div>
</td>
</tr>
<tr class="altColor" id="i8">
<td class="colFirst"><code>abstract boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isDirect()">isDirect</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether or not this buffer is
<a href="ByteBuffer.html#direct"><i>direct</i></a>.</div>
</td>
</tr>
<tr class="rowColor" id="i9">
<td class="colFirst"><code>abstract boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isReadOnly()">isReadOnly</a></span>()</code></th>
<td class="colLast">
<div class="block">Tells whether or not this buffer is read-only.</div>
</td>
</tr>
<tr class="altColor" id="i10">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#limit()">limit</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns this buffer's limit.</div>
</td>
</tr>
<tr class="rowColor" id="i11">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#limit(int)">limit</a></span>​(int newLimit)</code></th>
<td class="colLast">
<div class="block">Sets this buffer's limit.</div>
</td>
</tr>
<tr class="altColor" id="i12">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#mark()">mark</a></span>()</code></th>
<td class="colLast">
<div class="block">Sets this buffer's mark at its position.</div>
</td>
</tr>
<tr class="rowColor" id="i13">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#position()">position</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns this buffer's position.</div>
</td>
</tr>
<tr class="altColor" id="i14">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#position(int)">position</a></span>​(int newPosition)</code></th>
<td class="colLast">
<div class="block">Sets this buffer's position.</div>
</td>
</tr>
<tr class="rowColor" id="i15">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#remaining()">remaining</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the number of elements between the current position and the
limit.</div>
</td>
</tr>
<tr class="altColor" id="i16">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#reset()">reset</a></span>()</code></th>
<td class="colLast">
<div class="block">Resets this buffer's position to the previously-marked position.</div>
</td>
</tr>
<tr class="rowColor" id="i17">
<td class="colFirst"><code><a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#rewind()">rewind</a></span>()</code></th>
<td class="colLast">
<div class="block">Rewinds this buffer.</div>
</td>
</tr>
<tr class="altColor" id="i18">
<td class="colFirst"><code>abstract <a href="Buffer.html" title="class in java.nio">Buffer</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#slice()">slice</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a new buffer whose content is a shared subsequence of
this buffer's content.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods declared in class java.lang.<a href="../lang/Object.html" title="class in java.lang">Object</a></h3>
<code><a href="../lang/Object.html#clone()">clone</a>, <a href="../lang/Object.html#equals(java.lang.Object)">equals</a>, <a href="../lang/Object.html#finalize()">finalize</a>, <a href="../lang/Object.html#getClass()">getClass</a>, <a href="../lang/Object.html#hashCode()">hashCode</a>, <a href="../lang/Object.html#notify()">notify</a>, <a href="../lang/Object.html#notifyAll()">notifyAll</a>, <a href="../lang/Object.html#toString()">toString</a>, <a href="../lang/Object.html#wait()">wait</a>, <a href="../lang/Object.html#wait(long)">wait</a>, <a href="../lang/Object.html#wait(long,int)">wait</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="capacity()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>capacity</h4>
<pre class="methodSignature">public final int capacity()</pre>
<div class="block">Returns this buffer's capacity.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The capacity of this buffer</dd>
</dl>
</li>
</ul>
<a id="position()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>position</h4>
<pre class="methodSignature">public final int position()</pre>
<div class="block">Returns this buffer's position.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The position of this buffer</dd>
</dl>
</li>
</ul>
<a id="position(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>position</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> position​(int newPosition)</pre>
<div class="block">Sets this buffer's position. If the mark is defined and larger than the
new position then it is discarded.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>newPosition</code> - The new position value; must be non-negative
and no larger than the current limit</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - If the preconditions on <code>newPosition</code> do not hold</dd>
</dl>
</li>
</ul>
<a id="limit()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>limit</h4>
<pre class="methodSignature">public final int limit()</pre>
<div class="block">Returns this buffer's limit.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The limit of this buffer</dd>
</dl>
</li>
</ul>
<a id="limit(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>limit</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> limit​(int newLimit)</pre>
<div class="block">Sets this buffer's limit. If the position is larger than the new limit
then it is set to the new limit. If the mark is defined and larger than
the new limit then it is discarded.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>newLimit</code> - The new limit value; must be non-negative
and no larger than this buffer's capacity</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - If the preconditions on <code>newLimit</code> do not hold</dd>
</dl>
</li>
</ul>
<a id="mark()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mark</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> mark()</pre>
<div class="block">Sets this buffer's mark at its position.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
</dl>
</li>
</ul>
<a id="reset()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reset</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> reset()</pre>
<div class="block">Resets this buffer's position to the previously-marked position.
<p> Invoking this method neither changes nor discards the mark's
value. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="InvalidMarkException.html" title="class in java.nio">InvalidMarkException</a></code> - If the mark has not been set</dd>
</dl>
</li>
</ul>
<a id="clear()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clear</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> clear()</pre>
<div class="block">Clears this buffer. The position is set to zero, the limit is set to
the capacity, and the mark is discarded.
<p> Invoke this method before using a sequence of channel-read or
<i>put</i> operations to fill this buffer. For example:
<blockquote><pre>
buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data</pre></blockquote>
<p> This method does not actually erase the data in the buffer, but it
is named as if it did because it will most often be used in situations
in which that might as well be the case. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
</dl>
</li>
</ul>
<a id="flip()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flip</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> flip()</pre>
<div class="block">Flips this buffer. The limit is set to the current position and then
the position is set to zero. If the mark is defined then it is
discarded.
<p> After a sequence of channel-read or <i>put</i> operations, invoke
this method to prepare for a sequence of channel-write or relative
<i>get</i> operations. For example:
<blockquote><pre>
buf.put(magic); // Prepend header
in.read(buf); // Read data into rest of buffer
buf.flip(); // Flip buffer
out.write(buf); // Write header + data to channel</pre></blockquote>
<p> This method is often used in conjunction with the <a href="ByteBuffer.html#compact()"><code>compact</code></a> method when transferring data from
one place to another. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
</dl>
</li>
</ul>
<a id="rewind()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>rewind</h4>
<pre class="methodSignature">public <a href="Buffer.html" title="class in java.nio">Buffer</a> rewind()</pre>
<div class="block">Rewinds this buffer. The position is set to zero and the mark is
discarded.
<p> Invoke this method before a sequence of channel-write or <i>get</i>
operations, assuming that the limit has already been set
appropriately. For example:
<blockquote><pre>
out.write(buf); // Write remaining data
buf.rewind(); // Rewind buffer
buf.get(array); // Copy data into array</pre></blockquote></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>This buffer</dd>
</dl>
</li>
</ul>
<a id="remaining()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>remaining</h4>
<pre class="methodSignature">public final int remaining()</pre>
<div class="block">Returns the number of elements between the current position and the
limit.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The number of elements remaining in this buffer</dd>
</dl>
</li>
</ul>
<a id="hasRemaining()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hasRemaining</h4>
<pre class="methodSignature">public final boolean hasRemaining()</pre>
<div class="block">Tells whether there are any elements between the current position and
the limit.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if, and only if, there is at least one element
remaining in this buffer</dd>
</dl>
</li>
</ul>
<a id="isReadOnly()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isReadOnly</h4>
<pre class="methodSignature">public abstract boolean isReadOnly()</pre>
<div class="block">Tells whether or not this buffer is read-only.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if, and only if, this buffer is read-only</dd>
</dl>
</li>
</ul>
<a id="hasArray()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hasArray</h4>
<pre class="methodSignature">public abstract boolean hasArray()</pre>
<div class="block">Tells whether or not this buffer is backed by an accessible
array.
<p> If this method returns <code>true</code> then the <a href="#array()"><code>array</code></a>
and <a href="#arrayOffset()"><code>arrayOffset</code></a> methods may safely be invoked.
</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if, and only if, this buffer
is backed by an array and is not read-only</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6</dd>
</dl>
</li>
</ul>
<a id="array()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>array</h4>
<pre class="methodSignature">public abstract <a href="../lang/Object.html" title="class in java.lang">Object</a> array()</pre>
<div class="block">Returns the array that backs this
buffer <i>(optional operation)</i>.
<p> This method is intended to allow array-backed buffers to be
passed to native code more efficiently. Concrete subclasses
provide more strongly-typed return values for this method.
<p> Modifications to this buffer's content will cause the returned
array's content to be modified, and vice versa.
<p> Invoke the <a href="#hasArray()"><code>hasArray</code></a> method before invoking this
method in order to ensure that this buffer has an accessible backing
array. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The array that backs this buffer</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="ReadOnlyBufferException.html" title="class in java.nio">ReadOnlyBufferException</a></code> - If this buffer is backed by an array but is read-only</dd>
<dd><code><a href="../lang/UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - If this buffer is not backed by an accessible array</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6</dd>
</dl>
</li>
</ul>
<a id="arrayOffset()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>arrayOffset</h4>
<pre class="methodSignature">public abstract int arrayOffset()</pre>
<div class="block">Returns the offset within this buffer's backing array of the first
element of the buffer <i>(optional operation)</i>.
<p> If this buffer is backed by an array then buffer position <i>p</i>
corresponds to array index <i>p</i> + <code>arrayOffset()</code>.
<p> Invoke the <a href="#hasArray()"><code>hasArray</code></a> method before invoking this
method in order to ensure that this buffer has an accessible backing
array. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The offset within this buffer's array
of the first element of the buffer</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="ReadOnlyBufferException.html" title="class in java.nio">ReadOnlyBufferException</a></code> - If this buffer is backed by an array but is read-only</dd>
<dd><code><a href="../lang/UnsupportedOperationException.html" title="class in java.lang">UnsupportedOperationException</a></code> - If this buffer is not backed by an accessible array</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6</dd>
</dl>
</li>
</ul>
<a id="isDirect()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isDirect</h4>
<pre class="methodSignature">public abstract boolean isDirect()</pre>
<div class="block">Tells whether or not this buffer is
<a href="ByteBuffer.html#direct"><i>direct</i></a>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if, and only if, this buffer is direct</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.6</dd>
</dl>
</li>
</ul>
<a id="slice()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>slice</h4>
<pre class="methodSignature">public abstract <a href="Buffer.html" title="class in java.nio">Buffer</a> slice()</pre>
<div class="block">Creates a new buffer whose content is a shared subsequence of
this buffer's content.
<p> The content of the new buffer will start at this buffer's current
position. Changes to this buffer's content will be visible in the new
buffer, and vice versa; the two buffers' position, limit, and mark
values will be independent.
<p> The new buffer's position will be zero, its capacity and its limit
will be the number of elements remaining in this buffer, its mark will be
undefined. The new buffer will be direct if, and only if, this buffer is
direct, and it will be read-only if, and only if, this buffer is
read-only. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The new buffer</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
<a id="duplicate()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>duplicate</h4>
<pre class="methodSignature">public abstract <a href="Buffer.html" title="class in java.nio">Buffer</a> duplicate()</pre>
<div class="block">Creates a new buffer that shares this buffer's content.
<p> The content of the new buffer will be that of this buffer. Changes
to this buffer's content will be visible in the new buffer, and vice
versa; the two buffers' position, limit, and mark values will be
independent.
<p> The new buffer's capacity, limit, position and mark values will be
identical to those of this buffer. The new buffer will be direct if, and
only if, this buffer is direct, and it will be read-only if, and only if,
this buffer is read-only. </p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The new buffer</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>9</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../index.html">Overview</a></li>
<li><a href="../../module-summary.html">Module</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Buffer.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small><a href="https://bugreport.java.com/bugreport/">Report a bug or suggest an enhancement</a><br> For further API reference and developer documentation see the <a href="https://docs.oracle.com/pls/topic/lookup?ctx=javase12.0.2&id=homepage" target="_blank">Java SE Documentation</a>, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.<br> Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.<br> <a href="../../../../legal/copyright.html">Copyright</a> © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.<br>All rights reserved. Use is subject to <a href="https://www.oracle.com/technetwork/java/javase/terms/license/java12.0.2speclicense.html">license terms</a> and the <a href="https://www.oracle.com/technetwork/java/redist-137594.html">documentation redistribution policy</a>. <!-- Version 12.0.2+10 --></small></p>
</footer>
</body>
</html>