F:\sshc625\sshc625\JCreator Pro\MyProjects\Hello\Testingtemp.java:21: cannot resolve symbol
symbol  : constructor BufferedReader (java.io.FileInputStream)
location: class java.io.BufferedReader
      BufferedReader in=new BufferedReader(new FileInputStream(from));

解决方案 »

  1.   

    import java.lang.*;
    import java.io.*;public class Testingtemp 
    {
       public static void main(String[] args)
                          throws FileNotFoundException
       {
          File a1=new File("a.txt");
          File b1=new File("b.txt");      getTextFromHtml(a1,b1);
          
          //System.out.println();
       }
       
       public static void getTextFromHtml(File f,File to)
       {
          File from=f;
          File toText=to;
          try
          {
          BufferedReader in=new BufferedReader(new FileReader(from));
          String line=in.readLine();    
          
          PrintWriter outToText=
          new PrintWriter(new FileOutputStream(toText));
          
          if(line==null||line.trim().length()==0)
          System.out.println("There is't any content!");
          else
          //converttxt(line); 
          outToText.print(line);
          }
          catch(FileNotFoundException e1)
          {
             e1.printStackTrace();                  
          }
          catch(IOException e2)
          {
             e2.printStackTrace();                   
          }
          
       }
       
       public static String converttxt(String aContent)
       {
          String content=aContent;
          content=content.replaceAll("[<]([^>]*)[>]","");
          return content;
       }
    }
    我试图将A中的内容写入B中,可是就是实现不了,希望大家指点。55555555555555555
      

  2.   

    import java.io.*;
    public class  Testingtemp
    {
    public static void copy(String from_name, String to_name)
    throws IOException
    {
    File from_file = new File(from_name);  
    File to_file = new File(to_name);
     
    if (!from_file.exists())
    abort("没有这样的源文件: " + from_name);
    if (!from_file.isFile())
    abort("不能复制目录: " + from_name);
    if (!from_file.canRead())
    abort("源文件不是可读文件: " + from_name);
    if (to_file.isDirectory())
    to_file = new File(to_file, from_file.getName()); String parent = to_file.getParent();  
    if (parent == null)     
           parent = System.getProperty("user.dir");
       File dir = new File(parent);          
    if (!dir.exists())
    abort("目标目录不存在。 "+parent);
    if (dir.isFile())
    abort("指定的目标不是目录 " + parent);
    if (!dir.canWrite())
    abort("指定的目标目录不是可写的 " + parent);     

    FileInputStream from = null;  
    FileOutputStream to = null;   
    try {
    from = new FileInputStream(from_file);  
    to = new FileOutputStream(to_file);    
    byte[] buffer = new byte[4096];         
    int bytes_read;                          while((bytes_read = from.read(buffer)) != -1) 
    to.write(buffer, 0, bytes_read);           
    }
       
    finally {
    if (from != null) try { from.close(); } catch (IOException e) { ; }
    if (to != null) try { to.close(); } catch (IOException e) { ; }
    }
    }
        private static void abort(String msg) throws IOException { 
    throw new IOException("文件复制: " + msg); 
    }

        public static void main(String[] args) {
        try { copy("a.txt", "b.txt"); }
                catch (IOException e) { System.err.println(e.getMessage());} 
        }
    }我给你写了一个,应该能满足你的需要,如果有什么问题,叫我一下,共同学习,[email protected]
      

  3.   

    public static void getTextFromHtml(File f,File to) throws Exception
       {
          FileInputStream from=new FileInputStream(f);
          FileOutputStream toText=new FileOutputStream(to);
          int i;
          while(true){
             i=from.read();
             if(i==-1) break;
             //if you wann to filter sth.
             //converttxt(((char)i)+"");
             toText.write((byte)i);
             toText.flush();
          }
          from.close();from=null;
          toText.close();toText=null;
           
       }
      

  4.   

    move to technological IO
      

  5.   

    关键问题在这句上:
    BufferedReader in=new BufferedReader(new FileInputStream(from));
    BufferedReader读的是字符流,而FileInputStream读的是字节流,前者不能直接封装后者。
    应该这样写:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(from)));
    InputStreamReader实现字节流到字符流的转换
      

  6.   

    这一句:
    BufferedReader in=new BufferedReader(new FileInputStream(from));改为:
    BufferedReader in=new BufferedReader(new InputStreamkReader(new FileInputStream(from)));