从txt路径加载

@param path
@return
542193
public boolean load(String path)
    {
        trie = new DoubleArrayTrie<V>();
        long start = System.currentTimeMillis();
        if (loadDat(ByteArray.createByteArray(path + BIN_EXT)))
        {
            return true;
        }
        TreeMap<String, V> map = new TreeMap<String, V>();
        try
        {
            BufferedReader br = new BufferedReader(new InputStreamReader(IOUtil.newInputStream(path), "UTF-8"));
            String line;
            while ((line = br.readLine()) != null)
            {
                String[] paramArray = line.split("\\s");
                map.put(paramArray[0], createValue(paramArray));
            }
            br.close();
        }
        catch (Exception e)
        {
            logger.warning("读取" + path + "失败" + e);
            return false;
        }
        onLoaded(map);
        Set<Map.Entry<String, V>> entrySet = map.entrySet();
        List<String> keyList = new ArrayList<String>(entrySet.size());
        List<V> valueList = new ArrayList<V>(entrySet.size());
        for (Map.Entry<String, V> entry : entrySet)
        {
            keyList.add(entry.getKey());
            valueList.add(entry.getValue());
        }
        int resultCode = trie.build(keyList, valueList);
        if (resultCode != 0)
        {
            logger.warning("trie建立失败");
            return false;
        }
        logger.info(path + "加载成功，耗时" + (System.currentTimeMillis() - start) + "ms");
        saveDat(path + BIN_EXT, valueList);
        return true;
    }
108139
String withPath(String[] path) {
        StringBuilder sb = new StringBuilder();
        if (path.length > 0) {
            sb.append(" (with path ");
            for (int i = 0; i < path.length - 1; i++) {
                sb.append(path[i]);
                sb.append(".");
            }
            sb.append(path[path.length - 1]);
            sb.append(") ");
        }
        return sb.toString();

    }
864509
private String getStringResource(String path) {
    	InputStream in = getClass().getResourceAsStream(path);
    	
    	StringBuilder index = new StringBuilder();
    	char[] buffer = new char[1024];
    	int read = 0;
    	try(InputStreamReader reader = new InputStreamReader(in)){
    		while((read = reader.read(buffer)) != -1) {
    			index.append(buffer, 0, read);
    		}
    	} catch (IOException e) {
    		//just return what we've got
    		return index.toString();
    	}
    	return index.toString();
    }
163379
public LOADSTATUS loadFont(String path) throws VectorPrintException {
      try {
         File f = new File(path);
         LOADSTATUS stat = LOADSTATUS.NOT_LOADED;

         if (loadAWTFonts) {
            Font fo = Font.createFont(Font.TRUETYPE_FONT, f);
            GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo);
            stat = LOADSTATUS.LOADED_ONLY_AWT;
         }

         if (loadiText) {
            FontFactory.register(path);
            stat = (stat.equals(LOADSTATUS.LOADED_ONLY_AWT)) ? LOADSTATUS.LOADED_ITEXT_AND_AWT : LOADSTATUS.LOADED_ONLY_ITEXT;
            log.info(String.format("font loaded from %s", f.getAbsolutePath()));
         }

         return stat;
      } catch (FontFormatException | IOException ex) {
         log.log(Level.SEVERE, null, ex);

         throw new VectorPrintException("failed to load " + path, ex);
      }
   }
244964
private ArrayList<String[]> loadDict(String path) throws IOException {
		Scanner scanner = new Scanner(new FileInputStream(path), "utf-8");
		ArrayList<String[]> al = new ArrayList<String[]>();
		while(scanner.hasNext()) {
			String line = scanner.nextLine().trim();
			if(line.length() > 0) {
				String[] s = line.split("\\s");
				al.add(s);
			}
		}
		scanner.close();
		return al;
	}
1121960
public static InputStream newInputStream(String path) throws IOException
    {
        if (IOAdapter == null) return new FileInputStream(path);
        return IOAdapter.open(path);
    }
117822
public boolean load(String path)
    {
        String binPath = path + Predefine.BIN_EXT;
        if (load(ByteArrayStream.createByteArrayStream(binPath))) return true;
        if (!loadTxt(path)) return false;
        try
        {
            logger.info("正在缓存" + binPath);
            DataOutputStream out = new DataOutputStream(IOUtil.newOutputStream(binPath));
            save(out);
            out.close();
        }
        catch (Exception e)
        {
            logger.warning("缓存" + binPath + "失败：\n" + TextUtility.exceptionToString(e));
        }

        return true;
    }
271872
private static String fileAsString(String path) throws Exception {
        StringBuffer buffer = new StringBuffer();
        InputStream fis = new FileInputStream(path);
        InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
        Reader in = new BufferedReader(isr);
        int ch;
        while ((ch = in.read()) > -1) {
            buffer.append((char) ch);
        }
        in.close();
        return buffer.toString();
    }
888576
public JSON readFromFile( String path ) {
      return readFromStream( Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream( path ) );
   }
1041815
public static BufferedInputStream getInputStream(Path path) throws IORuntimeException {
		try {
			return new BufferedInputStream(Files.newInputStream(path));
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1140696
public Jar addEntry(Path path, Path file) throws IOException {
        return addEntry(path, Files.newInputStream(file));
    }
110362
public Jar addEntry(Path path, String file) throws IOException {
        return addEntry(path, Paths.get(file));
    }
207257
public static String hash(Path path) {
        try (InputStream in = Files.newInputStream(path)) {
            return hash(in);
        } catch (IOException e) {
            throw Exceptions.propagate(e);
        }
    }
1098745
public Jar addEntry(String path, byte[] content) throws IOException {
        beginWriting();
        addEntry(jos, path, content);
        return this;
    }
653891
public static BufferedWriter newBufferedWriter(Path path) throws IOException {
        FileUtils.checkDirectory(path.getParent());
        BufferedWriter bufferedWriter;
        if (path.toFile().getName().endsWith(".gz")) {
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(path.toFile()))));
        } else {
            bufferedWriter = Files.newBufferedWriter(path, Charset.defaultCharset());
        }
        return bufferedWriter;
    }
662009
public static InputStream asInputStream(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newInputStream(path);
	}
117853
public static String getResource(final String path) {
		final InputStream stream = getResourceStream(path);
		final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
		final Stream<String> lines = reader.lines();
		return lines.collect(Collectors.joining("\n"));
	}