有这么一段代码:
1 | try { |
代码很简单,就是将111 压缩后输出到SD卡中的test文件中,以上代码基本是没啥毛病的,但唯独在4.4上会导致异常,异常如下:
Caused by: java.util.zip.DataFormatException: stream error
at java.util.zip.Deflater.deflateImpl(Native Method)
at java.util.zip.Deflater.deflateImpl(Deflater.java:241)
at java.util.zip.Deflater.deflate(Deflater.java:232)
at java.util.zip.DeflaterOutputStream.flush(DeflaterOutputStream.java:193)
at cn.demonk.roboding.test1.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5266)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1091)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.access$800(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5217)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
出错在
out.flush()
上。