/**
* 从zip包中把AndroidManifest.xml文件拷贝出来
* @param file
* @param fileName
*/
public void copyMainfest(File file) {
ZipFile zipFile = null;
ZipInputStream zipInput = null;
ZipEntry zipEntry = null;
OutputStream os = null;
InputStream is = null;
File mainfestFile = new File(file.getParent() + "\\AndroidManifest.xml");
if(!mainfestFile.exists()){
try {
mainfestFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
zipFile = new ZipFile(file);
zipInput = new ZipInputStream(new FileInputStream(file),Charset.forName("utf-8"));
os = new FileOutputStream(mainfestFile);
while((zipEntry = zipInput.getNextEntry()) != null){
if(zipEntry.getName().equals("AndroidManifest.xml")){
is = zipFile.getInputStream(zipEntry);
int len;
while((len = is.read()) != -1){
os.write(len);
}
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
is.close();
os.close();
zipInput.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java 从zip包中复制文件
最新推荐文章于 2023-09-05 09:28:27 发布