怎样用Java以2进制形式打开一个文件? FileInputStream ,FileOutputStream 都是依二进制的形式打开文件的,还有好多的,在java.io.*里面 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 class fileinputstream { public static void main(String args[]) throws Exception { int size; FileInputStream fileinputstream = new FileInputStream("fileinputstream.java"); System.out.println("Available bytes: " + (size = fileinputstream.available())); System.out.println("Reading 50 bytes...."); byte bytearray[] = new byte[50]; if (fileinputstream.read(bytearray) != 50) { System.out.println("Could not get 50 bytes"); } System.out.println(new String(bytearray, 0, 50)); System.out.println("Skipping 50 bytes..."); fileinputstream.skip(50); System.out.println("Reading 50 bytes...."); if (fileinputstream.read(bytearray) != 50) { System.out.println("Could not get 50 bytes"); } System.out.println(new String(bytearray, 0, 50)); fileinputstream.close(); }} 用java.io.RandomAccessFile打开后都是以字节为单位操作。 serial中的getInputString与getOutputString的具体用法。 关于package和import的疑问 求一个简单的小程序,题目如下 这个例子应该怎么跑啊?有人能给说说么? 求尚学堂面试视频 null->0的问题。hashMap取不着值得的时候 在上海做对日软件程序员待遇有多少?本人以前没有对日开发的经验,做过2年的软件开发。 动态添加控件问题 swing 打印~~~~如何打印ie页面中的图像和文本的混合体(ie本身的打印功能不可以) 如何给JCheckBox 属性赋值 有没有这样的软件?关于UML 连接远程ODBC服务器
{
public static void main(String args[]) throws Exception
{
int size;
FileInputStream fileinputstream = new FileInputStream("fileinputstream.java"); System.out.println("Available bytes: " + (size = fileinputstream.available()));
System.out.println("Reading 50 bytes...."); byte bytearray[] = new byte[50];
if (fileinputstream.read(bytearray) != 50) {
System.out.println("Could not get 50 bytes");
} System.out.println(new String(bytearray, 0, 50)); System.out.println("Skipping 50 bytes..."); fileinputstream.skip(50); System.out.println("Reading 50 bytes....");
if (fileinputstream.read(bytearray) != 50) {
System.out.println("Could not get 50 bytes");
}
System.out.println(new String(bytearray, 0, 50)); fileinputstream.close();
}
}
打开后都是以字节为单位操作。