skip when reading Stream - Android File Input Output

Android examples for File Input Output:InputStream

Description

skip when reading Stream

Demo Code


import android.support.annotation.NonNull;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Main{
    public static boolean skip(@NonNull InputStream stream, int count,
            String tag) {/*w w  w  .ja  v a2  s.c  o m*/
        int length = 0;
        long skip;

        if (count > 0) {
            try {
                while (length < count) {
                    skip = stream.skip(count - length);
                    length += skip;
                }
            } catch (IOException e) {
                LogUtil.e(tag, "skip error at " + length + "/" + count
                        + ", " + e.getMessage());
            }
        }

        return length == count;
    }
}

Related Tutorials