实验四 Java 输入输出流 1 .实验目的(1) 掌握输入输出流的总体结构; (2) 掌握流的概念; (3) 了解各种流(包括文件流、过滤流、对象的序列化、随机访问)的使用。 2 .实验内容实验题 1 编写一个 Java Application 程序,打印命令行输入的所有参数。[ 基本要求] 编写完整程序。运行结果: 代码如下: import ; public mandOutPut { /** * ***@param args */ public static void main(String[] args) { // TODO Auto-generated method stub System. out .println( "Please input :" ); Scanner in = new Scanner(System. in ); String str = (); System. out .println( "The output results :" ); System. out .println(str); (); }} 实验题 2 通过键盘输入路径, 搜索指定路径下的全部内容。运行结果: 代码如下: .; import ; import ; import ; public class Output { /** * ***@param args * ***@throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub String fileName = "d:\\" ; File file = new File(fileName); byte [] b= new byte [( int )()]; FileInputStream out= new FileInputStream(file); (b); (); String s= new String(b); // 将字节流转换为字符串 System. out .println(s); }} 实验题 3 设计一个类 FileRWTest, 实现从 文件中读入数据到字符数组 cBuffer 中,然后再写入到文件“ output .txt ”中。运行结果: 代码: .; import ; import ; import ; import ; import ; public class FileRWTest { /** * ***@param args * ***@throws IOException */ public static voi
实验04 Java输入输出流报告 来自淘豆网www.taodocs.com转载请标明出处.