锘??xml version="1.0" encoding="utf-8" standalone="yes"?>91性高湖久久久久久久久_久久99,欧美国产日韩一区二区,亚洲乱码精品一二三四区日韩在线 http://www.aygfsteel.com/oldboy/category/30446.html<marquee><font face="妤蜂綋">鍦ㄩ潪媧茬殑澶ц崏鍘熶笂錛屾瘡澶╁綋澶槼鍗囪搗鐨勬椂鍊欙紝姣忓ご緹氱緤閮界煡閬擄紝濡傛灉瀹冭窇寰楁瘮鏈蹇殑涓澶寸寧璞硅繕瑕佹參錛岄偅瀹冨氨瑕佸け鍘葷敓鍛斤紱鍚屾牱鐨勶紝姣忓ご鐚庤憊涔熸噦寰楋紝濡傛灉瀹冭窇寰楁瘮鏈鎱㈢殑閭eご緹氱緤榪樿鎱紝瀹冧篃浼?xì)澶卞幦潝熷懡銆?lt;/font></marquee> zh-cn Tue, 25 Jan 2011 14:29:30 GMT Tue, 25 Jan 2011 14:29:30 GMT 60 BufferedInputStream綾諱腑鐨刴ark錛坕nt readlimit錛夋柟娉?/title> http://www.aygfsteel.com/oldboy/articles/195583.htmlOldBoy OldBoy Thu, 24 Apr 2008 06:45:00 GMT http://www.aygfsteel.com/oldboy/articles/195583.html http://www.aygfsteel.com/oldboy/comments/195583.html http://www.aygfsteel.com/oldboy/articles/195583.html#Feedback 5 http://www.aygfsteel.com/oldboy/comments/commentRss/195583.html http://www.aygfsteel.com/oldboy/services/trackbacks/195583.html 瀵逛簬BufferedInputStream綾諱腑鐨刴ark(int readlimit)鏂規(guī)硶鐨勪嬌鐢紝寰堝浜虹殑鐤戞儜鏄細(xì)鍙傛暟readlimit絀剁珶璧蜂粈涔堜綔鐢紵
濂借薄緇檙eadlimit璧嬩換浣曟暣鏁板肩粨鏋滈兘鏄竴鏍楓?br />
1 package io;
2
3 import java.io. * ;
4
5 public class BufInputStrm_A {
6
7 public static void main(String[] args) throws IOException {
8 String s = " ABCDEFGHI@JKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ;
9 byte [] buf = s.getBytes();
10 ByteArrayInputStream in = new ByteArrayInputStream(buf);
11 BufferedInputStream bis = new BufferedInputStream(in, 13 );
12 int i = 0 ;
13 int k;
14 do {
15 k = bis.read();
16 System.out.print(( char ) k + " " );
17 i ++ ;
18
19 if (i == 4 ) {
20 bis.mark( 8 );
21 }
22 } while (k != ' @ ' );
23
24 System.out.println();
25
26 bis.reset();
27 k = bis.read();
28 while (k != - 1 ) {
29
30 System.out.print(( char ) k + " " );
31 k = bis.read();
32 }
33
34 }
35 }
36
澶囨敞錛氫負(fù)浜嗘柟渚胯鏄庨棶棰橈紝鎴戜滑鍋囪瑕佽鍙栫殑鏄竴涓瓧絎︿覆錛堢8琛屼唬鐮侊級錛屽悓鏃舵妸緙撳瓨鐨勫ぇ灝忚緗負(fù)浜?3錛堢11琛屼唬鐮侊級銆?br />
鍦ㄧ20琛屼唬鐮佸璋冪敤浜唌ark(int readlimit)鏂規(guī)硶錛屼絾鏃犺緇欒鏂規(guī)硶浼?1銆?銆?3銆?00紼嬪簭杈撳嚭鐨勭粨鏋滈兘鏄竴鏍鳳細(xì)
A B C D E F G H I @
E F G H I @ J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z
鍦ㄥ畼鏂圭殑API甯姪鏂囨。涓紝瀵逛簬readlimit榪欎釜鍙傛暟鐨勮В閲婃槸錛?br />
readlimit
- the maximum limit of bytes that can be read before the mark position becomes invalid.
鍏跺疄錛岃繖閲岀殑鏈澶у瓧鑺傛暟錛坱he maximum limit of bytes錛夋槸鎸囪皟鐢╮eset()鏂規(guī)硶涔嬪悗錛岃鍙栬秴榪噐eadlimit鎸囧畾鐨勫瓧鑺傛暟錛屾爣璁扮淮錛坱he mark position錛変細(xì)澶辨晥錛屽鏋滆繖鏃跺啀嬈¤皟鐢╮eset()鏂規(guī)硶錛屼細(xì)鍑虹幇Resetting to invalid mark 寮傚父銆備緥濡備笅闈㈢殑紼嬪簭錛?br />
1 package io;
2
3 import java.io. * ;
4
5 public class BufInputStrm_A {
6
7 public static void main(String[] args) throws IOException {
8 String s = " ABCDEFGHI@JKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ;
9 byte [] buf = s.getBytes();
10 ByteArrayInputStream in = new ByteArrayInputStream(buf);
11 BufferedInputStream bis = new BufferedInputStream(in, 13 );
12 int i = 0 ;
13 int k;
14 do {
15 k = bis.read();
16 System.out.print(( char ) k + " " );
17 i ++ ;
18
19 if (i == 4 ) {
20 bis.mark( 8 );
21 }
22 } while (k != ' @ ' );
23
24 System.out.println();
25
26 bis.reset();
27 k = bis.read();
28 while (k != - 1 ) {
29
30 System.out.print(( char ) k + " " );
31 k = bis.read();
32 }
33
34 System.out.println();
35
36 bis.reset();
37 k = bis.read();
38 while (k != - 1 ) {
39 System.out.print(( char ) k + " " );
40 k = bis.read();
41
42 }
43
44 }
45 }
46
濡傛灉鎴戜滑鍦ㄧ涓嬈¤皟鐢ㄤ簡reset()鏂規(guī)硶涔嬪悗錛屾帶鍒惰鍏ョ殑瀛楄妭涓嶈秴榪?涓紝紼嬪簭灝變細(xì)姝e父鎵ц錛屼緥濡傛垜浠涓婇潰鐨勭▼搴忕殑26-32浠g爜鐢ㄤ笅闈㈢殑浠g爜鏇挎崲錛岀▼搴忓氨鍙互姝e父榪愯浜嗐?br />
bis.reset();
int j = 1 ;
k = bis.read();
while (j < 9 ) {
System.out.print(( char ) k + " " );
k = bis.read();
j ++ ;
}
琛ュ厖錛?br />
鍦╩ark(int readlimit)鏂規(guī)硶鐨勪唬鐮佷腑錛宺eadlimit鐨勫間細(xì)璧嬬粰鏁版嵁鍩焟arklimit錛屽鏋渕arklimit鐨勫煎ぇ浜庣紦鍐插尯鐨勫糂ufferedInputStream浼?xì)瀵咕~撳啿鍖虹殑澶у皬榪涜璋冩暣錛岃皟鏁翠負(fù)marklimit鐨勫箋?/p>
]]>鏄皝瀹炵幇浜咺terator鎺ュ彛錛?/title> http://www.aygfsteel.com/oldboy/articles/189238.htmlOldBoy OldBoy Fri, 28 Mar 2008 04:29:00 GMT http://www.aygfsteel.com/oldboy/articles/189238.html http://www.aygfsteel.com/oldboy/comments/189238.html http://www.aygfsteel.com/oldboy/articles/189238.html#Feedback 2 http://www.aygfsteel.com/oldboy/comments/commentRss/189238.html http://www.aygfsteel.com/oldboy/services/trackbacks/189238.html 濡傛灉搴旂敤Java闆嗗悎妗嗘灦錛屽緢澶氭椂鍊欓兘浼?xì)鐢ㄥ?/span>Iterator 鎺ュ彛綾誨瀷鐨勫璞″闆嗗悎涓殑鍏冪礌榪涜閬嶅巻銆備絾瀵婚亶Java API甯姪鏂囨。錛屽嵈鎵句笉鍒頒換浣曠被瀹炵幇浜咺terator鎺ュ彛銆傞偅涔堝埌搴曟槸璋佸疄鐜頒簡榪欎釜鎺ュ彛鍛紵
鍏跺疄錛屽洜涓轟笉鍚岄泦鍚堝疄鐜扮被鍚庡彴宸ヤ綔鐨勬暟鎹粨鏋勬湁鎵涓嶅悓錛屾墍浠ユ病鏈夊姙娉曠敤涓涓被鏉ュ疄鐜?/span>Iterator 鎺ュ彛錛屽彲浠ヤ嬌涔嬮傜敤浜庢墍鏈夐泦鍚堛傝繖鏍鳳紝瀹炵幇 Iterator 鎺ュ彛鐨勪換鍔″氨钀藉埌浜嗛泦鍚堝疄鐜扮被鑷繁韜笂銆?/span>
鐢變簬瀹炵幇浜咺terator鎺ュ彛鐨勭被浠呬笌鍏蜂綋鐨勯泦鍚堝疄鐜扮被鏈夊叧錛屾墍浠ヨ繖涓被琚璁℃垚浜?strong>縐佹湁鐨勫唴閮ㄧ被錛屼篃姝e洜涓鴻繖鏍鋒垜浠湪甯姪鏂囨。涓湅涓嶅埌榪欎釜綾葷殑璇存槑銆?/span>
涓嬮潰浠ユ暟緇勫疄鐜扮殑綰挎ц〃涓轟緥錛屽仛涓涓畝鍗曠殑婕旂ず錛岀浉淇$湅榪囦簡榪欐浠g爜錛屽ぇ瀹跺氨浼?xì)娓呮浜嗐?/span>
璇存槑錛氭垜浠繖閲屼富瑕佹槸璁茶В Iterator 鎺ュ彛鐨勪嬌鐢紝鎵浠ュ湪榪欎釜渚嬪瓙涓彧鎻愪緵浜哸dd鍜実et涓や釜鏂規(guī)硶錛屼互鍑忓皯浠g爜錛屼究浜庡ぇ瀹墮槄璇匯?/p>
package javase.study.oldboy;
import java.util.Iterator;
public class OurArrayList < E > implements Iterable < E > {
private E[] datas;
private int size;
public OurArrayList() {
this ( 16 );
}
@SuppressWarnings(" unchecked " )
public OurArrayList( int capacity) {
datas = (E[]) new Object[capacity];
size = 0 ;
}
@SuppressWarnings(" unchecked " )
public void add( int index, E obj) {
if (size >= datas.length) {
E[] newData = (E[]) new Object[datas.length * 2 + 1 ];
System.arraycopy(datas, 0 , newData, 0 , datas.length);
datas = newData;
}
for ( int i = size - 1 ; i >= index; i -- )
datas[i + 1 ] = datas[i];
datas[index] = obj;
size ++ ;
}
public E get( int index) {
if (index < size) {
return (E) datas[index];
} else
return null ;
}
public Iterator < E > iterator() {
return new Itr<E> ();
}
private class Itr implements Iterator {
int count = 0 ;
public boolean hasNext() {
return count < size;
}
public E next() {
return get(count ++ );
}
@Override
public void remove() {
// TODO Auto-generated method stub
}
}
}
]]>
主站蜘蛛池模板:
通榆县 |
墨竹工卡县 |
甘洛县 |
清水县 |
龙门县 |
宁乡县 |
北流市 |
霍州市 |
化隆 |
习水县 |
金乡县 |
玛多县 |
五原县 |
扶余县 |
安阳县 |
连城县 |
蓝山县 |
日喀则市 |
家居 |
英吉沙县 |
克山县 |
淄博市 |
宝丰县 |
泗洪县 |
辽中县 |
清徐县 |
三穗县 |
樟树市 |
平凉市 |
宝兴县 |
呼玛县 |
夏河县 |
梁山县 |
托里县 |
巢湖市 |
汉源县 |
永川市 |
仪征市 |
开化县 |
清新县 |
红河县 |