Created
July 26, 2016 06:49
-
-
Save AlbertHG/3c6bd410a14628107b93c22ac0e315fd to your computer and use it in GitHub Desktop.
读取二进制文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 读取二进制文件 | |
* @author A | |
* | |
*/ | |
class BinaryFile { | |
public static byte[] read(File file) throws IOException { | |
BufferedInputStream bf = new BufferedInputStream(new FileInputStream(file)); | |
try { | |
byte[] data = new byte[bf.available()]; | |
bf.read(data); | |
return data; | |
} finally { | |
bf.close(); | |
} | |
} | |
final static byte[] raed (String bFile) throws IOException{ | |
return read(new File(bFile).getAbsoluteFile()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
简化二进制读取文件过程