Since I started to use Android and Java, I have had many "amazing" contact with jvm and its gc mechanism. Many jvm gc implementations have different strategies. I personally know that, even the implementations of various Android mobile phone manufacturers (of course, strictly speaking, Android is not a JVM) are even different. What you encounter is really tearful
This article provides 2 pieces of Android code, the implementation of the download from the Android client zip file and implementation of the ZIP file decompression function, very practical, the need for Android developers can try.
Download:
Downloadertask.java
Cop
After more than n days, when I use the original blog article again:
Android compression and decompression zip fileWhen I decompressed the zip package, many problems were not found. The first is the problem of Chinese characters. The java zip package cannot solve the problem of decompression.
The value in getRealFileNam
PrefaceThis article is mainly through the introduction if the Android Studio installed when the solution of the package errors and ideas, the award of the Mermaid than the grant of fish.Environment:
Operating system: Windows 7 SP1
Android Build Environment: Android Studio 2.3.1
jdk:jdk1.8.0_102
Error:Gradle sync Failed:Cause:error in opening
Recently need to compress the output files, understand the next Android compression function, the source code is as follows:Activity invocation:Try { ziputil2.zip (Exportpath, Exportpath+ ". zip"); Catch (Exception e) { // TODO auto-generated catch block e.printstacktrace (); } Compression class Prototypes: Package
The problem was discovered by chance when this compilation was published in the previous period:
Zip error:invalid Command Arguments (cannot repeat names in zip file) Make: * * * [out/target/product/k200_hdmiin/system/etc /recovery-resource.dat] Error 16make: * * * waiting for unfinished jobs ....
Background Introduction
Bo Master is currently engaged in Androidtvbox development, based on
Error:Failed to complete Gradle executionCause:error in opening zip file.Reason:Installation Gradle failure, often is the need to verify the Internet or Internet access rights have not been caused;Solve:1. Delete the original residual information firstRM-RF ~/.gradle ~/androidstudioprojects/.gradle2. Check the network configuration, ensure normal Internet access, Android Stadio Agent Internet configuration
Download and decompress the Zip file based on Android, and update the simple help class of the UI
Download file:
/*** Download File ** @ param down_url * @ param output * @ param tmpDir */private void download (String down_url, File output, File tmpDir) {InputStream inputStream = null; outputStream outputStream = null; File tmp = null; int down_step = 1; // prompt step int totalSize = 0; int downloadCount
1. Error message:03-31 16:48:43.740:info/activitymanager: Start proc Com.android.packageinstaller for activity com.android.packageinstaller/. packageinstalleractivity:pid=620 uid=10026 gids={}03-31 16:48:44.749:warn/zipro (620): Unable to open zip '/data/data/ com.my.app/cache/myapp.apk ': Permission denied03-31 16:48:44.749:debug/asset (620): Failed to open Zip archive '/data/ data/com.my.app/cache/myapp.a
Android built-in zip for easy compression and decompression
In the development process, a zip package is used and a tool class is written. This class can be used to directly compress strings into a zip format, eliminating the need to write files and then compress them:
/***** @ Author shx * compression and decompressi
Some time ago, the company developed the javaee project and the website provided download for Android applications. The results showed that the APK files downloaded by many 3G online users were changed to zip files, but the database is stored in the APK file path, recently cannot be understood, our company uses apache-tomcat7, I took a look at tomcat, it is found that there is a file web under conf under th
The development process used a ZIP compression package, wrote a tool class, the class can be implemented to compress the string directly into the ZIP format, eliminating the need to write to the file to compress the steps:/** * * @author shx * Compression and Decompression tool * */public class Ziputil {/** * compression method * @param str to compress the string * @param path PATH * @throws Ioexce ption */
upyunaddress) {//If the picture has been uploaded, it should not be uploaded if (textutils. IsEmpty(Picture. GetSource())) {try {//Use another tool class provided by the cloud, upload image S Tring Path = Upyunutil. Uploadimage(Upyunaddress, picture. Getlocalurl());Gets the final URL of String FinalURL = upyunaddress. Getprefix() + Path;Picture. SetSource(FinalURL);} catch (Exception e) {E. Printstacktrace();}} return picture;} }). Subscribeon(schedulers. IO()). Observeon(android
This paper illustrates the method of compressing and decompressing the zip file with Android. Share to everyone for your reference. Specifically as follows:
Dirtraversal.java is as follows:
Package com.once;
Import Java.io.File;
Import java.util.ArrayList;
Import java.util.LinkedList; /** * Folder Traversal * @author Once * * */public class Dirtraversal {//no recursion public static linkedlist
The
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.