ReIn

package JBJADV003;

import java.io.*;
import java.util.Scanner;

public class ReIn {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FileInputStream fis=null;
try{
//创建输入流
fis=new FileInputStream("c:\\myDoc\\hello.txt");
//重定向到文件
System.setIn(fis);
Scanner sc=new Scanner(System.in);
System.out.print("从文件读取到的内容为:"+sc.next());

}catch(IOException ex){

}finally{
if(fis!=null){
fis.close();
}
}

}

}

posted on 2015-05-14 21:00  JesseCary  阅读(178)  评论(0)    收藏  举报

导航