String s="";
BufferedReader in=new BufferedReader (new InputStreamReader(System.in));
s=in.readLine();
rows=Integer.parseInt(s);
初学java,希望各位大虾多多指教!!
参考这个代码:
----------------------------------------------------
import java.io.*;
class fileWriteInfo {
void writeInfo()throws IOException{
int size=0;
byte b[]=new byte[6];
FileInputStream fin=new
FileInputStream("c:/java/abc.txt,true");
System.out.println("yes!");
FileOutputStream fout=new
FileOutputStream("c:/java/abc.txt,true");
try{
size=fin.available();
System.out.println("file size = "+size);
System.out.println("\nSkip the size :");
fin.skip(size);
System.out.print("Enter 6 chars: ");
for(int i=0;i<6;i++)
b[i]=(byte)System.in.read( );
fout.write(b);
}catch(IOException e){
System.out.print("file IOException!");
}finally{ fout.close( ); }
}
}
public class ReadAndWriteText {
public static void main(String args[])throws Exception {
fileWriteInfo obj=new fileWriteInfo ();
try{
obj.writeInfo();
}
catch(FileNotFoundException e) {
System.out.println("File not found : "+e);
throw e;
}catch(IOException e) {
System.out.println("File not found : "+e);
e.printStackTrace( );}
}
}