protected String encodeCookie(SerializableCookie serializableCookie) {
   OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
   try {
     new ObjectOutputStream(byteArrayOutputStream).writeObject(serializableCookie);
     return byteArrayToHexString(byteArrayOutputStream.toByteArray());
   } catch (Exception e) {
     return null;
   }
 }
Example #2
0
 public static String textCompress(String str) {
   try {
     Object array =
         ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(str.length()).array();
     OutputStream byteArrayOutputStream = new ByteArrayOutputStream(str.length());
     GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
     gZIPOutputStream.write(str.getBytes("UTF-8"));
     gZIPOutputStream.close();
     byteArrayOutputStream.close();
     Object obj = new byte[(byteArrayOutputStream.toByteArray().length + 4)];
     System.arraycopy(array, 0, obj, 0, 4);
     System.arraycopy(
         byteArrayOutputStream.toByteArray(),
         0,
         obj,
         4,
         byteArrayOutputStream.toByteArray().length);
     return Base64.encodeToString(obj, 8);
   } catch (Exception e) {
     Log.i(ConfigConstant.LOG_TAG, e.getMessage());
     return ConfigConstant.WIRELESS_FILENAME;
   }
 }
Example #3
0
 public final void m10156a(String str, String str2) {
   if (str2 == null) {
     this.f7295a.m7754a(str, null);
     return;
   }
   OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
   DataOutput dataOutputStream = new DataOutputStream(byteArrayOutputStream);
   try {
     if (str2 instanceof Boolean) {
       dataOutputStream.writeBoolean(((Boolean) str2).booleanValue());
     } else if (str2 instanceof String) {
       dataOutputStream.writeUTF(str2);
     } else if (str2 instanceof Integer) {
       dataOutputStream.writeInt(((Integer) str2).intValue());
     } else if (str2 instanceof Long) {
       dataOutputStream.writeLong(((Long) str2).longValue());
     } else {
       throw new IllegalArgumentException("Bad type: " + str2.getClass() + " for " + str);
     }
     this.f7295a.m7754a(str, byteArrayOutputStream.toByteArray());
   } catch (IOException e) {
     e.printStackTrace();
   }
 }