有一位先人曾经用过一个,还是国人写的,可是我找不到。
他说名字好像叫什么javacodefast之类的。
我找了一个下午,毫无收获!
希望有这方面信息的提供一下。
谢谢!

解决方案 »

  1.   

    自己动手写了一个java的程序,不过那位先人说那个程序不只这一个功能,我想是不是CGI或者PHP的什么小软件,里面的功能正好可以满足我所要求的功能。
    自己写的这个还很幼稚,在我的机器上没有中文问题(不包括文件名)。没有任何的界面,谁有兴趣做一个了。
    import java.io.*;class HtmltoServlet {   HtmltoServlet(String inputfile,String outputfile) {
    try {
          BufferedInputStream in = 
            new BufferedInputStream(
              new FileInputStream(
                inputfile));
          PrintStream out =
            new PrintStream(
              new BufferedOutputStream(
                new FileOutputStream(outputfile)));
          System.setIn(in);
          System.setOut(out);
          System.setErr(out);      BufferedReader br = 
            new BufferedReader(
              new InputStreamReader(System.in));
          String s;
         while((s = br.readLine()) != null)
      {
    String temp="";
    int current = -1;
            int end = 0;     try
    {
          end = s.indexOf("\"",current+1);
        /*----------------- parse ----------*/
              while(end!=-1){
               String value = s.substring(current+1,end);
          current = s.indexOf("\"",end);
          end = s.indexOf("\"",current+1);
          temp = temp + value +"\\\"" ;
                }
                {
                String value = s.substring(current+1,s.length());
          temp = temp + value;
                }
    }catch(Exception e){
               e.printStackTrace();
                }
            System.out.println("out.println(\""+temp+"\");");
    }
          out.close(); 
        } catch(IOException e) {
    System.out.println(e);
          e.printStackTrace();
        }
    }  public static void main(String[] args) {    if (args.length!=2)
      {
    System.out.println("java cuteText <inputfile fullname> <outputfile fullname>");
    System.exit(0);
    }
    HtmltoServlet hts = new HtmltoServlet(args[0],args[1]);  }
    }
      

  2.   

    使用StringBuffer的replace方法更省事
      

  3.   

    很久没有上来了。
    replace只能char到char,我怎么把"换成\"呢?
      

  4.   

    还有一个非常有意是的问题,下面是两个转换程序h2s.java和h2s_2.java:
    h2s.java文件为:
    import java.io.*;
    class h2s {
       h2s_2(String inputfile,String outputfile) {
    try {
          BufferedInputStream in = 
            new BufferedInputStream(
              new FileInputStream(
                inputfile));
          PrintStream out =
            new PrintStream(
              new BufferedOutputStream(
                new FileOutputStream(outputfile)));
          System.setIn(in);
          System.setOut(out);
          System.setErr(out);      BufferedReader br = 
            new BufferedReader(
              new InputStreamReader(System.in));
          String s="";
         while((s = br.readLine()) != null)
      {
    String temp="";
    int current = -1;
            int end = 0;
            s = s.trim();     try
    {
          end = s.indexOf("\"",current+1);
        /*----------------- parse ----------*/
              while(end!=-1){
               String value = s.substring(current+1,end);
          current = s.indexOf("\"",end);
          end = s.indexOf("\"",current+1);
          temp = temp + value +"\\\"" ;
                }
                {
                String value = s.substring(current+1,s.length());
          temp = temp + value;
                }
    }catch(Exception e){
               e.printStackTrace();
                }
    if (!temp.equals(""))
                System.out.println("out.println(\""+temp+"\");");
    }
          out.close(); 
        } catch(IOException e) {
    System.out.println(e);
          e.printStackTrace();
        }
    }  public static void main(String[] args) {    if (args.length!=2)
      {
    System.out.println("java h2s <inputfile fullname> <outputfile fullname>");
    System.exit(0);
    }
    h2s hts = new h2s(args[0],args[1]);
      }
    }
      

  5.   

    h2s_2.java文件为:import java.io.*;class h2s_2 {   h2s_2(String inputfile,String outputfile) {
    try {
          BufferedInputStream in = 
            new BufferedInputStream(
              new FileInputStream(
                inputfile));
          PrintStream out =
            new PrintStream(
              new BufferedOutputStream(
                new FileOutputStream(outputfile)));
          System.setIn(in);
          System.setOut(out);
          System.setErr(out);      BufferedReader br = 
            new BufferedReader(
              new InputStreamReader(System.in));
          String s="";
         while((s = br.readLine().trim()) != null)
      {
    String temp="";
    int current = -1;
            int end = 0;     try
    {
          end = s.indexOf("\"",current+1);
        /*----------------- parse ----------*/
              while(end!=-1){
               String value = s.substring(current+1,end);
          current = s.indexOf("\"",end);
          end = s.indexOf("\"",current+1);
          temp = temp + value +"\\\"" ;
                }
                {
                String value = s.substring(current+1,s.length());
          temp = temp + value;
                }
    }catch(Exception e){
               e.printStackTrace();
                }
    if (!temp.equals(""))
                System.out.println("out.println(\""+temp+"\");");
    }
          out.close(); 
        } catch(IOException e) {
    System.out.println(e);
          e.printStackTrace();
        }
    }  public static void main(String[] args) {    if (args.length!=2)
      {
    System.out.println("java h2s_2 <inputfile fullname> <outputfile fullname>");
    System.exit(0);
    }
    h2s_2 hts = new h2s_2(args[0],args[1]);  }
    }