对不起,我是因为不知如何写才求救的,虽简单,但对初学者也是一个难题,就如谁一开始就会写hellowrold!程序呢?

解决方案 »

  1.   

    public class MyCat { public static void main(String[] args) {
    StringBuffer buffer = new StringBuffer();
    StringBuffer fileName = new StringBuffer();
    char keyInput;

    System.out.println("Please input the String:");
    try {
    while((keyInput=(char) System.in.read())!='\n'){
    buffer.append(keyInput);
    }
    fileName.append(buffer.toString().substring(0,buffer.length()-1));
    } catch (IOException e) {
    e.printStackTrace();
    }
    System.out.println(buffer.toString());
    }
    }
      

  2.   

    jianlin(妞妞):
          不知道 fileName 有什么用处?