解决方案 »

  1.   

    我没看完,只看了一行你的main方法就没往下看了,你的main方法就定义错了,这样你的程序根本无法启动。main方法的定义
    public static void main(String [] args)
    不是
    public static void main(String args)
      

  2.   

    输出流关闭之前,请执行 flush()
      

  3.   

    我的程序写的是public static void main(String[] args)
    我也不知道怎么会变成那个字符串格式,应该是字符串数组格式。那里不纠结了
      

  4.   

    1.主方法问题
    2.流的刷新缓冲区
    3.流的关闭最好定义在 finally {} 中  
    4.路径的问题你最好检查下
      

  5.   

    import java.io.*;
    public class PrintStream6 {
    public static void main(String[] args) {
    String filename = args[0];
    String path = null;
    if(args.length < 2) {

    } else {
    path = args[1];
    }
    BufferedReader br = null;
    if (filename != null) {
    if(path != null) {
    printlist(filename,path);
    }else {
    printlist(filename,System.out);
    }
    }
    } public static void printlist(String f,PrintStream ps) {
    try {
    FileReader fr = new FileReader(f);
    BufferedReader br = new BufferedReader(fr);
    String s = null;
    while((s = br.readLine()) != null) {
    ps.println(s);
    }
    ps.flush();
    ps.close();
    fr.close();
    br.close();
    } catch(IOException e) {
    ps.println("文件无法读取!");
    }
     }
     
    public static void printlist(String f,String path) {
    FileReader fr = null;
    FileWriter fw = null;
    try {
    int s;
    fr = new FileReader(f);
    fw = new FileWriter(path);
    while((s = fr.read()) != -1) {
    fw.write(s);
    System.out.print((char)s);
    }
    fw.flush();
    fr.close();
    fw.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }