怎样用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打开后都是以字节为单位操作。 java异常处理 大家帮忙看看这道题 不好意思,只20分了。请问下啊,在用户登陆网站后,如何保存用户信息啊,就是说在任何页面以及我在后台写的类中得到这个值啊! 问一个关于java的小问题 POI读取EXCEL 画一个十个点的坐标轴 求教applet执行问题 如何知到SCROLL_SENSITIVEresultset型的ResultSet.和,ResultSet.TYPE_SCROLL_INSENSITIVE 型的ResultSet的行数 关于java的包的问题。 请教:rmi中的server为什么不能注册? 有没有这样的软件?关于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();
}
}
打开后都是以字节为单位操作。