⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vocabularyfilereader.java~13~

📁 辞典 这个是同学们一起编的一个辞典 JAVA开发的 希望能有用
💻 JAVA~13~
字号:
package com.io.file;import java.io.File;import java.util.Map;import java.util.HashMap;import java.io.LineNumberReader;import java.io.FileReader;/** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2008</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */public class VocabularyFileReader{    private File vocabularyFile = null;    private Map map = new HashMap(100000);    public VocabularyFileReader(File file)    {        this.setVocabularyFile(file);    }    public VocabularyFileReader(String filename, String flag)    {        this.setVocabularyFile(new File(filename));        this.setMap(null);    }    public void setVocabularyFile(File file)    {        this.vocabularyFile = file;    }    public Map getMap()    {        return this.map;    }    public void setMap(Map map)    {        try        {            if (map == null)            {                Map m = new HashMap();                String k = "";                String v = "";                LineNumberReader lnr = new LineNumberReader(new FileReader(this.vocabularyFile));                String line = lnr.readLine();                while (line != null)                {                    if (line.startsWith("+"))                    {                        if (k.length() > 0)                        {                            //show("MSG: key is " + k);                            //show("MSG: val is " + v);                            m.put(k, v);                        }                        k = line.substring(1, line.length());                        v = "";                    }                    else                    {                        v += line + "\n";                    }                    line = lnr.readLine();                }                this.map = m;            }            else            {                this.map = map;            }        }        catch (Exception ex)        {            ex.printStackTrace();        }    }    private void show(Object obj)    {        System.out.println(obj);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -