Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package apns;
 
 import java.util.Date;
 import java.util.List;
 
public class DefaultFeedbackService implements FeedbackService {
    public List<FailedDeviceTokenread(ApnsConnection connectionthrows ApnsException {
        if (connection == null) {
            throw new IllegalArgumentException("connection must not be null");
        }
        List<FailedDeviceTokentokens = new LinkedList<>();
        DataInputStream dis;
        try {
            dis = new DataInputStream(connection.getSocket().getInputStream());
        } catch (IOException e) {
            throw new ApnsException("Could not get input stream of socket"e);
        }
        try {
            readStream(distokens);
        } catch (IOException e) {
            throw new ApnsException("Could not read socket"e);
        }
        return tokens;
    }
    private void readStream(DataInputStream disList<FailedDeviceTokentokensthrows IOException {
        while (true) {
            long timestampInSec;
            try {
                timestampInSec = dis.readInt() & 0xffffffffL;
            } catch (EOFException e) {
                break;
            }
            int tokenLength = dis.readShort();
            byte[] token = new byte[32];
            dis.read(token);
            tokens.add(new FailedDeviceToken(new Date(timestampInSec * 1000), DeviceTokenHelper.deviceTokenBytesToString(token)));
        }
    }
New to GrepCode? Check out our FAQ X