本文整理汇总了Java中org.apache.commons.io.input.CountingInputStream.getByteCount方法的典型用法代码示例。如果您正苦于以下问题:Java CountingInputStream.getByteCount方法的具体用法?Java CountingInputStream.getByteCount怎么用?Java CountingInputStream.getByteCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.input.CountingInputStream
的用法示例。
在下文中一共展示了CountingInputStream.getByteCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readTable
import org.apache.commons.io.input.CountingInputStream; //导入方法依赖的package包/类
private static ArscData readTable(File file , CountingInputStream countIn, ExtDataInput in )
throws IOException {
ArscData arscData = new ArscData();
arscData.mFile = file;
arscData.mHeader = Header.read(in);
int packageCount = in.readInt();
if (packageCount != 1) {
throw new UnsupportedOperationException("not support more then 1 package");
}
arscData.mTableStrings = StringBlock.read(in);
arscData.mPkgHeaderIndex = (int) countIn.getByteCount();
arscData.mPkgHeader = PackageHeader.read(in);
arscData.mTypeStrStart = (int) countIn.getByteCount();
arscData.mTypeNames = StringBlock.read(in);
arscData.mTypeStrEnd = (int) countIn.getByteCount();
arscData.mSpecNames = StringBlock.read(in);
arscData.mResIndex = (int) countIn.getByteCount();
return arscData;
}
示例2: processSha1SyncResponse
import org.apache.commons.io.input.CountingInputStream; //导入方法依赖的package包/类
private boolean processSha1SyncResponse(Response response) throws IOException {
int expected = m_server.level() + 1;
CountingInputStream counter = new CountingInputStream(response.getResultStream());
InputStreamReader reader = new InputStreamReader(new BufferedInputStream(counter), UTF8.UTF8);
try {
m_server = new Gson().fromJson(reader, Sha1SyncJson.class);
if (expected != m_server.level()) {
throw new IllegalStateException("Level warp! expected("+expected+"), actual("+m_server.level()+")");
}
if (!versionFeatures.getToken().equals(m_server.version())) {
throw new IllegalStateException("Version warp! expected("+versionFeatures.getToken()+"), actual("+m_server.version()+")");
}
if (isServerEmpty()) {
clearLocal();
return true;
}
if (isServerHashesEmpty()) {
return true;
}
return false;
} finally {
m_rxBytes += counter.getByteCount();
reader.close();
}
}
示例3: copyWithNotifyProgress
import org.apache.commons.io.input.CountingInputStream; //导入方法依赖的package包/类
private void copyWithNotifyProgress(CountingInputStream source, OutputStream sink, DownloadableDocument document) throws IOException {
int n;
byte[] buffer = new byte[BUFFER_SIZE];
while((n = source.read(buffer)) > 0) {
sink.write(buffer, 0, n);
double progress = (double) source.getByteCount() / document.getSize();
notifyObserversProgress(document, progress);
}
}
示例4: readObjectFile
import org.apache.commons.io.input.CountingInputStream; //导入方法依赖的package包/类
private static List<Object> readObjectFile(File objectFile) throws IOException
{
long fileLength = objectFile.length();
FileInputStream fis = new FileInputStream(objectFile);
CountingInputStream cis = new CountingInputStream(fis);
ObjectInputStream ois = new ObjectInputStream(cis);
List<Object> objects = new ArrayList<Object>();
try
{
while (cis.getByteCount() < fileLength)
{
objects.add(ois.readObject());
}
}
catch (ClassNotFoundException e)
{
throw new IOException(e);
}
finally
{
ois.close();
}
return objects;
}
示例5: processGmlResponse
import org.apache.commons.io.input.CountingInputStream; //导入方法依赖的package包/类
void processGmlResponse(Response response) throws IOException, SAXException, ParserConfigurationException {
FeatureCollection<?, ?> features;
if (response instanceof ResponseFeatureCollection) {
ResponseFeatureCollection responseFeatures = (ResponseFeatureCollection) response;
features = responseFeatures.getFeatureCollection();
} else {
CountingInputStream counter = new CountingInputStream(response.getResultStream());
long s = System.currentTimeMillis();
features = (FeatureCollection<?, ?>) parseWfs(counter);
long e = System.currentTimeMillis();
m_parseMillis = e - s;
m_rxGml += counter.getByteCount();
}
FeatureIterator<?> it = features.features();
try {
while (it.hasNext()) {
Feature feature = it.next();
FeatureId fid = feature.getIdentifier();
m_potentialDeletes.remove(fid);
if (!m_features.containsKey(fid)) {
m_listener.featureCreate(fid, feature);
m_numCreates++;
} else {
m_listener.featureUpdate(fid, feature);
m_numUpdates++;
}
}
} finally {
it.close();
}
}