计算最长英语单词链

package bao;
import java.io.*;
import java.nio.file.Paths;
import java.util.Scanner;

public class text
{
    @SuppressWarnings("resource")
    public String get(String path) throws IOException
    {
        Scanner in = null;
        String file = "";
        in = new Scanner(Paths.get(path));
        while (in.hasNextLine())
        {
            file += in.nextLine();
        }
        return file;
    }

    public BufferedWriter put(String path)
    {
        try
        {
            FileWriter file1 = null;
            BufferedWriter bf = null;
            try
            {
                file1 = new FileWriter(path);
                bf = new BufferedWriter(file1);
            } catch (IOException e)
            {
                e.printStackTrace();
            }
            return bf;
        } catch (Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }
}

 

posted @ 2019-06-06 19:01    阅读(94)  评论(0编辑  收藏  举报