| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.util; |
| 18 |
|
| 19 |
import java.io.DataInputStream; |
| 20 |
import java.io.DataOutputStream; |
| 21 |
import java.io.IOException; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public class BackupUtils { |
| 28 |
|
| 29 |
public static final int NULL = 0; |
| 30 |
public static final int NOT_NULL = 1; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public static class BadVersionException extends Exception { |
| 37 |
public BadVersionException(String message) { |
| 38 |
super(message); |
| 39 |
} |
| 40 |
|
| 41 |
public BadVersionException(String message, Throwable throwable) { |
| 42 |
super(message, throwable); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
public static String readString(DataInputStream in) throws IOException { |
| 47 |
return (in.readByte() == NOT_NULL) ? in.readUTF() : null; |
| 48 |
} |
| 49 |
|
| 50 |
public static void writeString(DataOutputStream out, String val) throws IOException { |
| 51 |
if (val != null) { |
| 52 |
out.writeByte(NOT_NULL); |
| 53 |
out.writeUTF(val); |
| 54 |
} else { |
| 55 |
out.writeByte(NULL); |
| 56 |
} |
| 57 |
} |
| 58 |
} |