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

📄 indexpathbean.java

📁 simple spider 源码 better light faster java 书籍源码.
💻 JAVA
字号:
package com.develop.ss.config;

import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

public class IndexPathBean {

   private final String propFilePath = "index.properties";
   private String nextIndexPath;
   private String curIndexPath;
   private String nextIndex;
   private Properties props;

    private void getPaths() throws IOException
    {
        File f = new File(propFilePath);
        if (!f.exists()) {
          throw new IOException("properties path " + propFilePath + " does not exist");
        }
        props = new Properties();
        props.load(new FileInputStream(propFilePath));
        String indexRelativePath = props.getProperty("index.next");
        if (indexRelativePath == null) {
          throw new IllegalArgumentException("indexRelativePath not set in " + propFilePath);
        }
        nextIndex = Integer.toString(1 - Integer.parseInt(indexRelativePath));
        curIndexPath = props.getProperty("index.fullpath") + indexRelativePath;
        nextIndexPath = props.getProperty("index.fullpath") + nextIndex;
    }

    public String getFlippedIndexPath() throws IOException
    {
        getPaths();
        return nextIndexPath;
    }

     public String getIndexPath() throws IOException {
            getPaths();
            return curIndexPath;
      }
    public void flipIndexPath() throws IOException
    {

        props.setProperty("index.next", nextIndex);
        props.store(new FileOutputStream(propFilePath), "");
    }
}

⌨️ 快捷键说明

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