1
1
package training07 ;
2
2
3
- class BBB
4
- {
5
- int bbb ;
6
- private byte [] s ;
7
- public BBB () {
8
- bbb = 0 ;
9
- s = new byte [10 ];
10
- }
11
- }
12
-
13
- class DDD extends BBB
14
- {
15
- int ddd ;
16
- private byte [] ss = new byte [20 ];
17
- }
18
-
19
- class XXX {
20
- public DDD ddd ;
21
- };
22
-
23
3
class String {
24
4
public String () {
25
5
this .bytes = new byte [1 ];
@@ -44,8 +24,11 @@ public InputStream(String init) {
44
24
this .s = init .getBytes ();
45
25
}
46
26
int read (byte [] data , int shift , int count ) {
47
- for (int i = shift ; i != count ; ++i )
48
- data [i ] = this .s [i ];
27
+ for (int i = 0 ; i != count ; ++i ) {
28
+ if (i == this .s .length )
29
+ return i ;
30
+ data [shift + i ] = this .s [i ];
31
+ }
49
32
return count ;
50
33
}
51
34
private byte [] s ;
@@ -65,8 +48,11 @@ public OutputStream() {
65
48
this .s = new byte [100 ];
66
49
}
67
50
public void write (byte [] data , int shift , int count ) {
68
- for (int i = 0 ; i != count ; ++i )
51
+ for (int i = 0 ; i != count ; ++i ) {
52
+ if (i == this .s .length )
53
+ return ;
69
54
this .s [i ] = data [i ];
55
+ }
70
56
}
71
57
public void write (byte [] data ) {
72
58
write (data ,0 ,data .length );
@@ -117,12 +103,11 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
117
103
int size = getBytes (data ,in );
118
104
String str0 = new String (data , 0 , size );
119
105
String str = str0 ;
120
- // str = sanitise(str);
106
+ str = sanitise (str );
121
107
OutputStream out0 = getOutStream (response );
122
108
OutputStream out = out0 ;
123
109
out .write (data ,0 ,size );
124
110
out .write (str .getBytes ());
125
- foo ();
126
111
}
127
112
128
113
private InputStream getInStream (HttpServletRequest request ) {
@@ -143,11 +128,5 @@ private String sanitise(String str) {
143
128
private OutputStream getOutStream (HttpServletResponse response ) {
144
129
return response .getOutputStream ();
145
130
}
146
-
147
- public void foo () {
148
- XXX xxx = new XXX ();
149
- xxx .ddd = new DDD ();
150
- }
151
131
}
152
132
153
-
0 commit comments