这是,update那个工程里,更换rom的脚本。
- try {
FileOutputStream f1 = context.openFileOutput("info.txt", 0);
OutputStreamWriter w = new OutputStreamWriter(f1);
w.write(mRes.getString(R.string.PREF_LAST_UPDATE_CHECK)+"="+d.getTime());
w.flush();
w.close();
f1.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- FileInputStream fis = context.openFileInput("info.txt");
InputStreamReader reader = new InputStreamReader(fis);
BufferedReader r = new BufferedReader(reader);
String sb="";
try {
sb = r.readLine();
Log.d(TAG, sb);
sb = sb.split("=")[1];//用=作标志,分成两端,取第二段
time = new Date(Long.valueOf(sb));
} catch (IOException e) {
e.printStackTrace();
}
-
try
{
URL url = new URL("http://192.168.4.195:8080/change.zip");
InputStream is = url.openStream();
OutputStream os = openFileOutput("change.zip", 0);
byte[] buff = new byte[1024];
int hasRead = 0;
while((hasRead = is.read(buff)) > 0)
{
os.write(buff, 0, hasRead);
}
is.close();
os.close();
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("wrong");
}