public static void getBitFromString(String string) {
try {
FileWriter fw = new FileWriter("c:\\a.txt");
byte[] byts = string.getBytes();
for (int i = 0; i < byts.length; i++) {
fw.write(byts[i]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void getBitFromByte(byte[] byts) {
try {
FileWriter fw = new FileWriter("c:\\a.txt");
String result = "";
for (int i = 0; i < byts.length; i++) {
result += Integer.toBinaryString(byts[i]);
}
fw.write(result);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
写入二进制文件
最新推荐文章于 2023-10-25 22:32:08 发布