CharStreams.java
4.1 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
package com.google.common.io;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.List;
import ra;
@Beta
public final class CharStreams
{
public static Writer asWriter(Appendable paramAppendable)
{
if ((paramAppendable instanceof Writer)) {
return (Writer)paramAppendable;
}
return new ra(paramAppendable);
}
public static long copy(Readable paramReadable, Appendable paramAppendable)
throws IOException
{
Preconditions.checkNotNull(paramReadable);
Preconditions.checkNotNull(paramAppendable);
CharBuffer localCharBuffer = CharBuffer.allocate(2048);
long l = 0L;
while (paramReadable.read(localCharBuffer) != -1)
{
localCharBuffer.flip();
paramAppendable.append(localCharBuffer);
l += localCharBuffer.remaining();
localCharBuffer.clear();
}
return l;
}
public static Writer nullWriter()
{
return a.a();
}
public static <T> T readLines(Readable paramReadable, LineProcessor<T> paramLineProcessor)
throws IOException
{
Preconditions.checkNotNull(paramReadable);
Preconditions.checkNotNull(paramLineProcessor);
paramReadable = new LineReader(paramReadable);
String str;
do
{
str = paramReadable.readLine();
} while ((str != null) && (paramLineProcessor.processLine(str)));
return (T)paramLineProcessor.getResult();
}
public static List<String> readLines(Readable paramReadable)
throws IOException
{
ArrayList localArrayList = new ArrayList();
paramReadable = new LineReader(paramReadable);
for (;;)
{
String str = paramReadable.readLine();
if (str == null) {
break;
}
localArrayList.add(str);
}
return localArrayList;
}
public static void skipFully(Reader paramReader, long paramLong)
throws IOException
{
Preconditions.checkNotNull(paramReader);
while (paramLong > 0L)
{
long l = paramReader.skip(paramLong);
if (l == 0L)
{
if (paramReader.read() == -1) {
throw new EOFException();
}
paramLong -= 1L;
}
else
{
paramLong -= l;
}
}
}
public static String toString(Readable paramReadable)
throws IOException
{
StringBuilder localStringBuilder = new StringBuilder();
copy(paramReadable, localStringBuilder);
return localStringBuilder.toString();
}
static final class a
extends Writer
{
private static final a a = new a();
public final Writer append(char paramChar)
{
return this;
}
public final Writer append(CharSequence paramCharSequence)
{
Preconditions.checkNotNull(paramCharSequence);
return this;
}
public final Writer append(CharSequence paramCharSequence, int paramInt1, int paramInt2)
{
Preconditions.checkPositionIndexes(paramInt1, paramInt2, paramCharSequence.length());
return this;
}
public final void close() {}
public final void flush() {}
public final String toString()
{
return "CharStreams.nullWriter()";
}
public final void write(int paramInt) {}
public final void write(String paramString)
{
Preconditions.checkNotNull(paramString);
}
public final void write(String paramString, int paramInt1, int paramInt2)
{
Preconditions.checkPositionIndexes(paramInt1, paramInt1 + paramInt2, paramString.length());
}
public final void write(char[] paramArrayOfChar)
{
Preconditions.checkNotNull(paramArrayOfChar);
}
public final void write(char[] paramArrayOfChar, int paramInt1, int paramInt2)
{
Preconditions.checkPositionIndexes(paramInt1, paramInt1 + paramInt2, paramArrayOfChar.length);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/io/CharStreams.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/