打开字节值,该字节包含" textfile"
我有一个转换文件的android代码来自字节值
String root = Environment.getExternalStorageDirectory().getAbsolutePath();
File myDir = new File(root);
File fileWithinMyDir = new File(myDir, filename);
FileOutputStream dest = new FileOutputStream(fileWithinMyDir);
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(dest));
ZipEntry entry = new ZipEntry(filename);
entry.setSize(input.length);
zos.putNextEntry(entry);
zos.write(input);
zos.closeEntry();
zos.close();
但我试过快速4
let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
.appendingPathComponent("/download.zip")
print(fileURL)
if let outputStream = OutputStream(url: fileURL, append: true)
{
outputStream.open()
let bytesWritten = outputStream.write(bytes, maxLength: 1024)
if bytesWritten < 0
{
print("write failure")
}
outputStream.close().
}
我保存到文档目录并打开txt文件,它在打开txt文件时显示以下消息
无法打开文档。文件格式不正确
如何打开那个字节任何人帮助我