import java.io.*;public class iotest{
public static void main(String args[])throws IOException{
FileOutputStream fo=new FileOutputStream("F:\\t\t1.txt");
InputStreamReader is=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(is);
String s;
System.out.println("please enter something:");
System.out.flush();
s=br.readLine();
for(int i=0;i<s.length();i++){
fo.write(s.charAt(i));
}
fo.close();
FileInputStream fl=new FileInputStream("F:\\t\t.txt");
int number=fl.available();
System.out.println("No of bytes:"+number);
Byte[] inBuff=new Byte[number];
int readByte=fl.read(inBuff,0,number);
System.out.println("no.of bytes read:"+ readByte);
System.out.println("\n They are:"+ new String(inBuff));
fl.close();
System.out.println("\n deleing...");
File test=new File("F:\\t\t.txt");
test.delete();
}
}
F:\学习\java\IO\iotest.java:22: 找不到符号
符号: 方法 read(java.lang.Byte[],int,int)
位置: 类 java.io.FileInputStream
int readByte=fl.read(inBuff,0,number);
^
F:\学习\java\IO\iotest.java:24: 找不到符号
符号: 构造函数 String(java.lang.Byte[])
位置: 类 java.lang.String
System.out.println("\n They are:"+ new String(inBuff));
^
2 错误请请大家帮帮忙啊
public static void main(String args[])throws IOException{
FileOutputStream fo=new FileOutputStream("F:\\t\t1.txt");
InputStreamReader is=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(is);
String s;
System.out.println("please enter something:");
System.out.flush();
s=br.readLine();
for(int i=0;i<s.length();i++){
fo.write(s.charAt(i));
}
fo.close();
FileInputStream fl=new FileInputStream("F:\\t\t.txt");
int number=fl.available();
System.out.println("No of bytes:"+number);
Byte[] inBuff=new Byte[number];
int readByte=fl.read(inBuff,0,number);
System.out.println("no.of bytes read:"+ readByte);
System.out.println("\n They are:"+ new String(inBuff));
fl.close();
System.out.println("\n deleing...");
File test=new File("F:\\t\t.txt");
test.delete();
}
}
F:\学习\java\IO\iotest.java:22: 找不到符号
符号: 方法 read(java.lang.Byte[],int,int)
位置: 类 java.io.FileInputStream
int readByte=fl.read(inBuff,0,number);
^
F:\学习\java\IO\iotest.java:24: 找不到符号
符号: 构造函数 String(java.lang.Byte[])
位置: 类 java.lang.String
System.out.println("\n They are:"+ new String(inBuff));
^
2 错误请请大家帮帮忙啊
public static void main(String args[]) throws IOException {
FileOutputStream fo = new FileOutputStream("F:\\t\\t1.txt");//这里没有双写”\\“,下面也一样
InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
String s=null;
System.out.println("please enter something:");
System.out.flush();
s = br.readLine(); for (int i = 0; i < s.length(); i++) {
fo.write(s.charAt(i));
}
fo.close();
FileInputStream fl = new FileInputStream("F:\\t\\t1.txt");//你上面写t1.txt但你这里写t.txt
int number = fl.available();
System.out.println("No of bytes:" + number); byte[] inBuff = new byte[number];//这里错了
int readByte = fl.read(inBuff, 0, number);
System.out.println("no.of bytes read:" + readByte);
System.out.println("\n They are:" + new String(inBuff));
fl.close();
System.out.println("\n deleing..."); File test = new File("F:\\t\\t.txt");
test.delete();
}
}