java-以相反的顺序将文件转换为字节数组

byte[] bFile = new byte[(int) file.length()];

FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();

这段代码让我将文件转换为字节数组,我希望从头到尾读取文件(顺序相反)

编辑:我不会读取整个文件.末尾的一部分(例如约1000字节)

解决方法:

File file = new File(/*file path*/);
byte[] bFile = new byte[1000];

RandomAccessFile fileInputStream = new RandomAccessFile(file, "r");
fileInputStream.seek(fileInputStream.length() - bFile[0].length);
fileInputStream.read(bFile, 0, bFile.length);
fileInputStream.close();

我刚弄清楚,读取了文件的最后1000个字节

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...