实际上,我正在使用一种方法在我的android应用中压缩生成的txt文件,在以下txt文件中,有按回车符分隔的数据
123213213
123213132
424242244
但是,如果我压缩此文件并将其解压缩到计算机上,则以下文件将为
123213213□123213132□424242244
这是我用来压缩文件的方法
public void zip(String files, String zipFile) throws IOException {
BufferedInputStream origin;
try (ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)))) {
byte[] data = new byte[BUFFER_SIZE];
FileInputStream fi = new FileInputStream(files);
origin = new BufferedInputStream(fi, BUFFER_SIZE);
try {
ZipEntry entry = new ZipEntry(files.substring(files.lastIndexOf("/") + 1));
out.putNextEntry(entry);
int count;
while ((count = origin.read(data, 0, BUFFER_SIZE)) != -1) {
out.write(data, 0, count);
}
} finally {
origin.close();
}
}
}