Java读取文件内容并转换为字符串

来源:互联网 发布:nginx 新增模块 编辑:程序博客网 时间:2024/06/18 12:01
String FileName="d:/2.txt";
        File myFile
=new File(FileName);
        
if(!myFile.exists())
        

            System.err.println("Can't Find " + FileName);
        }


        
try 
        
{
            BufferedReader in = new BufferedReader(new FileReader(myFile));
            String str;
            while ((str = in.readLine()) != null
            {
                  System.out.println(str);
            }

            in.close();
        }
 
        
catch (IOException e) 
        
{
            e.getStackTrace();

        }

http://blog.sina.com.cn/s/blog_15e1433c30102wd1x.html
http://blog.sina.com.cn/s/blog_14d8952290102wii4.html
http://blog.sina.com.cn/s/blog_15e1433c30102wd20.html
http://tieba.baidu.com/p/4665234070
http://tieba.baidu.com/p/4667230793
http://tieba.baidu.com/p/4667235501

http://blog.sina.com.cn/s/blog_163f91c5e0102wnyx.html 


http://blog.sina.com.cn/s/blog_14d8952290102wii0.html

 System.err.println("Can't Find " + FileName);
        }


        
try 
        
{
            BufferedReader in = new BufferedReader(new FileReader(myFile));
            String str;
            while ((str = in.readLine()) != null
            {
                  System.out.println(str);
            }

            in.close();
        }
 
        
catch (IOException e) 
http://blog.sina.com.cn/s/blog_15e1433c30102wd1v.html

http://blog.sina.com.cn/s/blog_15e1433c30102wd1x.html
http://blog.sina.com.cn/s/blog_14d8952290102wii4.html
http://blog.sina.com.cn/s/blog_15e1433c30102wd20.html
http://tieba.baidu.com/p/4665234070
http://tieba.baidu.com/p/4667230793
http://tieba.baidu.com/p/4667235501

http://blog.sina.com.cn/s/blog_163f91c5e0102wnyx.html 


http://blog.sina.com.cn/s/blog_14d8952290102wii0.html


http://blog.sina.com.cn/s/blog_15e1433c30102wd1v.html

 System.err.println("Can't Find " + FileName);
        }


        
try 
        
{
            BufferedReader in = new BufferedReader(new FileReader(myFile));
            String str;
            while ((str = in.readLine()) != null
            {
                  System.out.println(str);
            }

            in.close();
        }
 
        
catch (IOException e) 


0 0