configbean.java

来自「simple spider 源码 better light faster ja」· Java 代码 · 共 94 行

JAVA
94
字号
package com.develop.ss.config;

import java.util.Properties;

public class ConfigBean {

    Properties props = new Properties();
    int maxlinks;
    String[] allowedExtensions;
    String skippedLinksFile;
    IndexPathBean indexPathBean = new IndexPathBean();
    String avoidLinks;

    public ConfigBean()
    {
        try
        {
            props.load(getClass().getResourceAsStream("/com.develop.ss.properties"));
            maxlinks = Integer.parseInt(props.getProperty("maxlinks"));
            allowedExtensions= props.getProperty("allowed.extensions").split(",");
            skippedLinksFile = props.getProperty("skipped.links.file");
            avoidLinks = props.getProperty("AvoidLinks");
        }
        catch(Exception ex)
        {

        }
    }

    public String getStringProperty(String propName)
    {
          return props.getProperty(propName);
    }
    public String[] getStringArrProperty(String propName, String sep)
    {
        return props.getProperty(propName).split(sep);
    }
    public String getSkippedLinksFile()
    {
        return skippedLinksFile;
    }
    public int getMaxLinks()
    {
        return maxlinks;
    }
    public String[] getAllowedExtensions()
    {
        return allowedExtensions;
    }

    public String getCurIndexPath()
    {
        String indexPath = "";
        try
        {
            indexPath = indexPathBean.getIndexPath();
        }
        catch(Exception ex)
        {
        }
        return indexPath;
    }

    public String getNextIndexPath()
    {
        String indexPath = "";
        try
        {
            indexPath = indexPathBean.getFlippedIndexPath();
        }
        catch(Exception ex)
        {
        }
        return indexPath;
    }

    public void flipIndexPath()
    {
        try
        {
            indexPathBean.flipIndexPath();
        }
        catch(Exception ex)
        {
        }
    }

    public String getAvoidLinks()
    {
        return avoidLinks;
    }

}

⌨️ 快捷键说明

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