import java.io.FileNotFoundException
import java.io.IOException
import java.io.RandomAccessFile
import java.nio.ByteBuffer
import java.nio.channels.FileChannel
public class CopyFile {
public static void main(String[] args) {
ByteBuffer bb=null
try {
// FileOutputStream fileOut=new FileOutputStream("f:\\1.txt")
// FileInputStream fileIn=new FileInputStream("f:\\2.txt")
RandomAccessFile raf=new RandomAccessFile("f://1.txt","rw")
RandomAccessFile rafo=new RandomAccessFile("f://2.txt","rw")
//获得写入和读取通道
FileChannel foc=raf.getChannel()
FileChannel fic=rafo.getChannel()
//分配缓冲区大小
bb=ByteBuffer.allocate(1024)
//将数据读入缓冲区
foc.read(bb)
bb.put("还可以加入数据".getBytes())
//反转数据,反转以后,不能再放数据
bb.flip()
fic.write(bb)
} catch (Exception e) {
}finally{
bb.clear()
}
}
}
下载dex2jar和JD-GUI,在参考资料中添加了这两个工具的百度网盘下载地址供读者下载使用(笔者亲测)
找到我们准备测试用的apk,并将 后缀.apk改为.zip
将test.zip解压,并查看目录,找到classes.dex
并将这个文件拷至dex2jar工具存放目录下
打开控制台,使用cd指令进入到dex2jar工具存放的目录下,如图
进入到dex2jar目录下后,输入“dex2jar.bat classes.dex”指令运行
执行完毕,查看dex2jar目录,会发现生成了classes.dex.dex2jar.jar文件
上一步中生成的classes.dex.dex2jar.jar文件,可以通过JD-GUI工具直接打开查看jar文件中的代码