st=buff.read();
-->
st=buff.readLine();
-->
st=buff.readLine();
解决方案 »
- 问一个算法,如何将数字反转(使用数学方法,不能将它转换成字符或者字符串)
- 请教:JDBC的事务问题
- 对getBytes的应用
- 百分求助 中文版(带模糊查询)JDK
- 求教,这样能删除数据库中的一行数据吗?
- 我用eclipse怎么那么不顺利呀,连helloworld都编译不过?
- Java编程的时候怎样有效的防止内存泄露?
- 类A为什么从外包继承一个protected成员后,类A的子类为什么不能访问这个成员
- 哪里有weblogic的中文文档?
- 在IE里浏览用CORBA连接数据库的Applet时出现如下错误:java.lang.ClassNotFoundException:org.mag.PortableServer.Servant,该如何解决?
- 视频文件截图(给点建议也给分)
- JSwing能否支持中文?
不用循环吧,如果是,System.out.println(st);不在循环内部,还不是一个输出
boolean set=buff.canread();不对
canRead() - Method in class java.io.File ,,另外大写canRead
import java.io.*;
public class Xyuan{
public static void main(String args[]) throws IOException {
FileInputStream file=new FileInputStream("e:\\xy.txt");
BufferedInputStream buff=new BufferedInputStream(file);
String st;
while(true){
st=buff.read();
}
buff.close();
int i=st.indexOf("xcv");
int b=st.indexOf('v');
String a=st.substring(i,b+1);
System.out.println(a);
}
错误在与st=buff.read();我不明白这是为什么????????
}
found : int
required: java.lang.String
st=buff.read();
^
1 error这就是这个程序的错误!!!请指正,谢谢!!!
public class Xyuan{
public static void main(String args[]) throws IOException {
DataInputStream ss=new DataInputStream(
new BufferedInputStream(
new FileInputStream("c:\\xy.txt") ));
//FileInputStream file=new FileInputStream("e:\\xy.txt");
//BufferedInputStream buff=new BufferedInputStream(file);
char t=(char)ss.readByte();
char [] sb=new char[ss.available()];
int i=0;
while(ss.available() != 0){
sb[i++]=t;
t=(char)ss.readByte();
}
String st=new String(sb);
i=st.indexOf("xcv");
int b=st.indexOf('v');
String a=st.substring(i,b+1);
System.out.println(a);
} }
while(true){
st=buff.read();
}
--------->
read()讀出來的是int型
而st是String,當然不匹配了