Debug
commit
7ec40106f1
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="aliyunpan-autobackup" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,97 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="AliAccessStaticViaInstance" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliDeprecation" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliEqualsAvoidNull" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliMissingOverrideAnnotation" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AliWrapperTypeEquality" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAbstractClassShouldStartWithAbstractNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidApacheBeanUtilsCopy" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidCallStaticSimpleDateFormat" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidCommentBehindStatement" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidComplexCondition" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidConcurrentCompetitionRandom" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidDoubleOrFloatEqualCompare" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidManuallyCreateThread" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidMissUseOfMathRandom" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidNegationOperator" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidNewDateGetTime" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidPatternCompileInMethod" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidReturnInFinally" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidStartWithDollarAndUnderLineNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaAvoidUseTimer" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaBigDecimalAvoidDoubleConstructor" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaBooleanPropertyShouldNotStartWithIs" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaClassCastExceptionWithSubListToArrayList" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaClassCastExceptionWithToArray" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaClassMustHaveAuthor" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaClassNamingShouldBeCamel" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaCollectionInitShouldAssignCapacity" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaCommentsMustBeJavadocFormat" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaConcurrentExceptionWithModifyOriginSubList" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaConstantFieldShouldBeUpperCase" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaCountDownShouldInFinally" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaDontModifyInForeachCircle" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaEnumConstantsMustHaveComment" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaExceptionClassShouldEndWithException" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaIbatisMethodQueryForList" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaLockShouldWithTryFinally" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaLowerCamelCaseVariableNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaMethodReturnWrapperType" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaMethodTooLong" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaPackageNaming" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaPojoMustOverrideToString" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaPojoMustUsePrimitiveField" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaPojoNoDefaultValue" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaRemoveCommentedCode" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaServiceOrDaoClassShouldEndWithImpl" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaStringConcat" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaSwitchStatement" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaTestClassShouldEndWithTestNaming" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaThreadLocalShouldRemove" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaThreadPoolCreation" enabled="false" level="BLOCKER" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaThreadShouldSetName" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaTransactionMustHaveRollback" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaUndefineMagicConstant" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaUnsupportedExceptionWithModifyAsList" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaUseQuietReferenceNotation" enabled="false" level="MAJOR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="AlibabaUseRightCaseForDateFormat" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="date" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="alimaven" />
|
||||||
|
<option name="name" value="alimaven" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SmartFoxProjectConfig">
|
||||||
|
<option name="projectInspectionClosed" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,5 @@
|
|||||||
|
[]
|
||||||
|
tokenText = 77190dd0a59a45b0883650647b85522d
|
||||||
|
pathText = C:\Users\Administrator\Desktop\HKBTest
|
||||||
|
folderText = backtest
|
||||||
|
backType = 0
|
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.eg</groupId>
|
||||||
|
<artifactId>aliyunpan-autobackup</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--okhttp3-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--工具类-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.6.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.7.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: com.eg.www.App
|
||||||
|
|
@ -0,0 +1,326 @@
|
|||||||
|
package com.eg.www;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.setting.Setting;
|
||||||
|
import com.eg.www.common.CommonConstants;
|
||||||
|
import com.eg.www.common.utils.AliYunPanUtil;
|
||||||
|
import com.eg.www.common.utils.FileUtil;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.plaf.FontUIResource;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: GUI
|
||||||
|
* Author: Eg
|
||||||
|
* Date: 2021/08/29
|
||||||
|
*/
|
||||||
|
public class AliYunPan extends JFrame implements ActionListener {
|
||||||
|
|
||||||
|
private static final int obj_left = 100;//左边距
|
||||||
|
private static final int text_width = 400;//文本框框
|
||||||
|
private static final int text_high = 30;//文本框高
|
||||||
|
private static final int title_left = 10;//标题左边距
|
||||||
|
private static final int title_width = 166;//标题宽
|
||||||
|
private static final int title_high = 25;//标题高
|
||||||
|
private static final int radio_top = 150;//标题高
|
||||||
|
private static final int radio_width = 100;//标题高
|
||||||
|
private static final int radio_high = 25;//标题高
|
||||||
|
|
||||||
|
//阿里云工具类
|
||||||
|
private AliYunPanUtil aliYunPanUtil=new AliYunPanUtil();
|
||||||
|
// 日志界面
|
||||||
|
JScrollPane consolePane = CommonConstants.consolePane;
|
||||||
|
JScrollBar scrollBar = CommonConstants.scrollBar;
|
||||||
|
//Token文本框
|
||||||
|
JTextField tokenText = CommonConstants.tokenText;
|
||||||
|
// 备份目录
|
||||||
|
private JTextField pathText;
|
||||||
|
// 目录名称
|
||||||
|
private JTextField folderText;
|
||||||
|
//选择文件夹按钮
|
||||||
|
private JButton selectBtn;
|
||||||
|
//选择文件夹
|
||||||
|
private JFileChooser selectPathChooser = new JFileChooser();
|
||||||
|
|
||||||
|
// 迭代一单选框
|
||||||
|
private JRadioButton puTongRadio;
|
||||||
|
// 迭代二单选框
|
||||||
|
private JRadioButton fenLeiRadio;
|
||||||
|
|
||||||
|
// 开始备份
|
||||||
|
private JButton startBackup = CommonConstants.startBackup;
|
||||||
|
// 暂停备份
|
||||||
|
private JButton pauseBackup;
|
||||||
|
|
||||||
|
//判断系统是否有托盘
|
||||||
|
static SystemTray tray = SystemTray.getSystemTray();
|
||||||
|
//托盘图标
|
||||||
|
private static TrayIcon trayIcon = null;
|
||||||
|
//配置文件
|
||||||
|
Setting setting =CommonConstants.setting;
|
||||||
|
|
||||||
|
public AliYunPan(){
|
||||||
|
//GUI默认配置
|
||||||
|
initConfig();
|
||||||
|
//初始化UI
|
||||||
|
initUi();
|
||||||
|
this.setVisible(true);
|
||||||
|
//初始化变量
|
||||||
|
CommonConstants.PATH = setting.getStr("pathText");
|
||||||
|
CommonConstants.REFRESH_TOKEN = setting.getStr("tokenText");
|
||||||
|
CommonConstants.BACK_NAME = setting.getStr("folderText");
|
||||||
|
if (StrUtil.isNotEmpty(setting.getStr("backType"))){
|
||||||
|
CommonConstants.BACK_TYPE = Integer.parseInt(setting.getStr("backType"));
|
||||||
|
}
|
||||||
|
//开启目录检测
|
||||||
|
aliYunPanUtil.monitorFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 程序默认配置
|
||||||
|
*/
|
||||||
|
private void initConfig() {
|
||||||
|
// 设置界面使用字体
|
||||||
|
FontUIResource fontUIResource = new FontUIResource(new Font("宋体", Font.PLAIN, 13));
|
||||||
|
for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
|
||||||
|
Object key = keys.nextElement();
|
||||||
|
Object value = UIManager.get(key);
|
||||||
|
if (value instanceof FontUIResource) {
|
||||||
|
UIManager.put(key, fontUIResource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//设置显示窗口标题
|
||||||
|
setTitle("备份助手");
|
||||||
|
//设置标题栏的图标
|
||||||
|
this.setIconImage(new ImageIcon(getClass().getResource("/images/logo.png")).getImage());
|
||||||
|
//设置窗口显示尺寸
|
||||||
|
setSize(800,600);
|
||||||
|
//窗口是否可以关闭
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
//默认居中显示
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
//禁止改变窗口大小
|
||||||
|
this.setResizable(false);
|
||||||
|
|
||||||
|
// 窗口最小化事件
|
||||||
|
this.addWindowListener(new WindowAdapter() {
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowIconified(WindowEvent e) {
|
||||||
|
setVisible(false);
|
||||||
|
miniTray();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initUi() {
|
||||||
|
// 初始化控件
|
||||||
|
Container container = getContentPane();
|
||||||
|
container.setLayout(null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左侧标题
|
||||||
|
*/
|
||||||
|
JLabel pathTitle = new JLabel("选择目录");
|
||||||
|
pathText = new JTextField();
|
||||||
|
JLabel tokenTitle = new JLabel("阿里云Token");
|
||||||
|
//tokenText = new JTextField();
|
||||||
|
JLabel folderTitle = new JLabel("备份目录名称");
|
||||||
|
folderText = new JTextField();
|
||||||
|
JLabel backTitle = new JLabel("备份模式");
|
||||||
|
backTitle.setBounds(title_left, 150, title_width, title_high);
|
||||||
|
container.add(backTitle);
|
||||||
|
// 路径选择区域
|
||||||
|
JPanel selectPanle = new JPanel();
|
||||||
|
selectPanle.setLayout(null);
|
||||||
|
|
||||||
|
//选择目录框
|
||||||
|
pathTitle.setBounds(title_left, 20, title_width, title_high);
|
||||||
|
container.add(pathTitle);
|
||||||
|
pathText.setText(setting.getStr("pathText"));
|
||||||
|
pathText.setBounds(obj_left, 20, text_width, text_high);
|
||||||
|
container.add(pathText);
|
||||||
|
|
||||||
|
//token框
|
||||||
|
tokenTitle.setBounds(title_left, 60, title_width, title_high);
|
||||||
|
container.add(tokenTitle);
|
||||||
|
tokenText.setText(setting.getStr("tokenText"));
|
||||||
|
tokenText.setBounds(obj_left, 60, text_width, text_high);
|
||||||
|
container.add(tokenText);
|
||||||
|
|
||||||
|
//目录名称框
|
||||||
|
folderTitle.setBounds(title_left, 100, title_width, title_high);
|
||||||
|
container.add(folderTitle);
|
||||||
|
folderText.setText(setting.getStr("folderText"));
|
||||||
|
folderText.setBounds(obj_left, 100, text_width, text_high);
|
||||||
|
container.add(folderText);
|
||||||
|
|
||||||
|
//选择文件按钮
|
||||||
|
selectBtn = new JButton("选择...");
|
||||||
|
selectBtn.setBounds(501, 22, 90, 25);
|
||||||
|
selectBtn.addActionListener(this);
|
||||||
|
container.add(selectBtn);
|
||||||
|
|
||||||
|
|
||||||
|
//读取设置中选中的模式
|
||||||
|
String type = setting.getStr("backType");
|
||||||
|
boolean pt_checked=false;
|
||||||
|
boolean fl_checked=false;
|
||||||
|
if (ObjectUtil.isNotNull(type)){
|
||||||
|
if (type.equals("0")){
|
||||||
|
pt_checked=true;
|
||||||
|
}else if (type.equals("1")){
|
||||||
|
fl_checked=true;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
pt_checked=true;
|
||||||
|
}
|
||||||
|
//模式选择
|
||||||
|
puTongRadio = new JRadioButton("普通备份",pt_checked);
|
||||||
|
puTongRadio.setBounds(100, radio_top, radio_width, radio_high);
|
||||||
|
puTongRadio.setBackground(container.getBackground());
|
||||||
|
container.add(puTongRadio);
|
||||||
|
fenLeiRadio = new JRadioButton("分类备份",fl_checked);
|
||||||
|
fenLeiRadio.setBounds(250, radio_top, radio_width, radio_high);
|
||||||
|
fenLeiRadio.setBackground(container.getBackground());
|
||||||
|
container.add(fenLeiRadio);
|
||||||
|
//设置为单选
|
||||||
|
ButtonGroup typeGroup = new ButtonGroup();
|
||||||
|
typeGroup.add(puTongRadio);
|
||||||
|
typeGroup.add(fenLeiRadio);
|
||||||
|
|
||||||
|
|
||||||
|
//startBackup = new JButton("开始备份");
|
||||||
|
startBackup.setFont(new Font("宋体", Font.PLAIN, 13));
|
||||||
|
startBackup.setBounds(100, 195, 100, 30);
|
||||||
|
startBackup.addActionListener(this);
|
||||||
|
container.add(startBackup);
|
||||||
|
pauseBackup = new JButton("暂停备份");
|
||||||
|
pauseBackup.setBounds(250, 195, 100, 30);
|
||||||
|
pauseBackup.addActionListener(this);
|
||||||
|
container.add(pauseBackup);
|
||||||
|
//日志面板
|
||||||
|
consolePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||||
|
scrollBar.setSize(100,100);
|
||||||
|
consolePane.setBounds(0, 240, 800, 348);
|
||||||
|
container.add(consolePane);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件处理器
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
//选择文件夹
|
||||||
|
if (e.getSource() == selectBtn) {
|
||||||
|
selectPathChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
int intRetVal = selectPathChooser.showOpenDialog(this);
|
||||||
|
if (intRetVal == JFileChooser.APPROVE_OPTION) {
|
||||||
|
pathText.setText(selectPathChooser.getSelectedFile().getPath());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (!checkText()){//验证
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//开始按钮
|
||||||
|
if (e.getSource() == startBackup) {
|
||||||
|
startBackup.setEnabled(false);
|
||||||
|
startBackup.setText("正在备份");
|
||||||
|
CommonConstants.CLEAN_CONSOLE=0;
|
||||||
|
//获取用户输入的token
|
||||||
|
CommonConstants.REFRESH_TOKEN=tokenText.getText();
|
||||||
|
setting.set("tokenText",CommonConstants.REFRESH_TOKEN);
|
||||||
|
//获取用户输入的目录
|
||||||
|
CommonConstants.PATH=pathText.getText();
|
||||||
|
setting.set("pathText",CommonConstants.PATH);
|
||||||
|
//获取用户输入的目录名称
|
||||||
|
CommonConstants.BACK_NAME=folderText.getText();
|
||||||
|
setting.set("folderText",CommonConstants.BACK_NAME);
|
||||||
|
//获取上传模式
|
||||||
|
CommonConstants.BACK_TYPE = puTongRadio.isSelected() ? 0 : 1;
|
||||||
|
setting.set("backType",CommonConstants.BACK_TYPE+"");
|
||||||
|
//输出模式
|
||||||
|
CommonConstants.addConsole("备份模式:"+(puTongRadio.isSelected() ? "普通模式" : "分类模式"));
|
||||||
|
setting.store(CommonConstants.CONFIG_PATH);
|
||||||
|
//执行上传文件操作
|
||||||
|
try {
|
||||||
|
Thread backup = new Thread(() -> aliYunPanUtil.startBackup());
|
||||||
|
backup.start();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
CommonConstants.addConsole("遇到异常情况:"+exc.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//暂停按钮
|
||||||
|
if (e.getSource() == pauseBackup) {
|
||||||
|
JOptionPane.showMessageDialog(null, "此功能正在开发中...", "提示", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证文本框输入
|
||||||
|
*/
|
||||||
|
public Boolean checkText(){
|
||||||
|
if (StrUtil.isEmpty(pathText.getText())){
|
||||||
|
JOptionPane.showMessageDialog(null, "您没有选择需要备份的目录", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(tokenText.getText())){
|
||||||
|
JOptionPane.showMessageDialog(null, "您没有输入阿里云token", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(folderText.getText())){
|
||||||
|
JOptionPane.showMessageDialog(null, "您没有输入需要备份到阿里云的目录", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tokenText.getText().length()!=32){
|
||||||
|
JOptionPane.showMessageDialog(null, "您输入的token不正确", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!FileUtil.isDirectory(pathText.getText())){
|
||||||
|
JOptionPane.showMessageDialog(null, "请选择正确目录", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//窗口最小化到任务栏托盘
|
||||||
|
private void miniTray() {
|
||||||
|
ImageIcon trayImg = new ImageIcon(JFrame.class.getClass().getResource("/images/logo.png"));//托盘图标
|
||||||
|
trayIcon = new TrayIcon(trayImg.getImage(), "备份助手");
|
||||||
|
trayIcon.setImageAutoSize(true);
|
||||||
|
|
||||||
|
//鼠标点击事件处理器
|
||||||
|
trayIcon.addMouseListener(new MouseAdapter() {
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
//if (e.getClickCount() ==2 ) {
|
||||||
|
// 鼠标点击一次打开软件
|
||||||
|
if (e.getClickCount() == 1) {
|
||||||
|
// 移去托盘图标
|
||||||
|
tray.remove(trayIcon);
|
||||||
|
setVisible(true);
|
||||||
|
//还原窗口
|
||||||
|
setExtendedState(JFrame.NORMAL);
|
||||||
|
toFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
tray.add(trayIcon);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("发生异常:"+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.eg.www;
|
||||||
|
|
||||||
|
import cn.hutool.cron.CronUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信备份程序
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App {
|
||||||
|
public static void main( String[] args ) {
|
||||||
|
//加载UI
|
||||||
|
new AliYunPan();
|
||||||
|
//开启定时
|
||||||
|
CronUtil.start();
|
||||||
|
//支持秒级别定时任务
|
||||||
|
CronUtil.setMatchSecond(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//获取用户输入的token
|
||||||
|
/*CommonConstants.REFRESH_TOKEN="ec06dae699d14c8e87e55372d92f4664";
|
||||||
|
//获取用户输入的目录
|
||||||
|
CommonConstants.PATH="F:\\用户目录\\文档\\WeChat Files\\wxid_3wc96wg6zgf022\\FileStorage\\File\\2021-05";
|
||||||
|
//获取用户输入的目录名称
|
||||||
|
CommonConstants.BACK_NAME="测试2";
|
||||||
|
//获取上传模式
|
||||||
|
CommonConstants.BACK_TYPE = 1;
|
||||||
|
AliYunPanUtil aliYunPanUtil=new AliYunPanUtil();
|
||||||
|
try {
|
||||||
|
aliYunPanUtil.startBackup();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("遇到异常情况:"+e.toString());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*AliYunPanUtil.getAliYunPanInfo();//登录阿里云
|
||||||
|
String wxFileId=AliYunPanUtil.getFileId(CommonConstants.ROOT, "公司-微信备份");//备份目录ID
|
||||||
|
List<String> folderList = FileUtil.fileFolderList(CommonConstants.PATH,FileUtil.FOLDER);
|
||||||
|
for (String folderName : folderList) {
|
||||||
|
System.out.println("folder:"+folderName);
|
||||||
|
String path = CommonConstants.PATH + FileUtil.FILE_SEPARATOR + folderName;//路径
|
||||||
|
List<String> fileList = FileUtil.fileFolderList(path,FileUtil.FILE);//本地文件夹下文件
|
||||||
|
for (String filePath : fileList) {
|
||||||
|
Map<String, Object> map = FileUtil.getFileInfo(filePath);
|
||||||
|
String type = map.get("type").toString();
|
||||||
|
String typeFileId=AliYunPanUtil.getFileId(wxFileId,type);//微信备份-类型
|
||||||
|
String dateFileId=AliYunPanUtil.getFileId(typeFileId,folderName);//微信备份-类型-日期
|
||||||
|
AliYunPanUtil.doUploadFile(dateFileId,map);
|
||||||
|
}
|
||||||
|
String folderFileId = AliYunPanUtil.getFileId(wxFileId, "文件夹");//微信备份-文件夹
|
||||||
|
String dateFileId = AliYunPanUtil.getFileId(folderFileId, folderName);//微信备份-文件夹-日期
|
||||||
|
AliYunPanUtil.scanFolders(path,dateFileId,false);
|
||||||
|
}
|
||||||
|
System.out.println("ok");*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Test(){
|
||||||
|
System.out.println(111);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.eg.www.common;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.io.file.FileReader;
|
||||||
|
import cn.hutool.core.io.file.FileWriter;
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
import cn.hutool.setting.Setting;
|
||||||
|
import com.eg.www.common.utils.FileUtil;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 公共变量
|
||||||
|
* Author: Eg
|
||||||
|
* Date: 2021/08/29
|
||||||
|
*/
|
||||||
|
public class CommonConstants {
|
||||||
|
|
||||||
|
//日志面板
|
||||||
|
public static MyConsole console = new MyConsole();
|
||||||
|
public static JScrollPane consolePane = new JScrollPane(console);
|
||||||
|
public static JScrollBar scrollBar = consolePane.getVerticalScrollBar();
|
||||||
|
// Token文本框
|
||||||
|
public static JTextField tokenText = new JTextField();
|
||||||
|
//开始备份按钮
|
||||||
|
public static JButton startBackup = new JButton("开始备份");
|
||||||
|
//当前路径
|
||||||
|
public static String SYSTEM_PATH = System.getProperty("user.dir") + File.separator;
|
||||||
|
//配置文件路径
|
||||||
|
public static String CONFIG_PATH = SYSTEM_PATH + "back_config.setting";
|
||||||
|
//配置文件
|
||||||
|
public static Setting setting = new Setting(FileUtil.touch(CONFIG_PATH).getPath(), true);
|
||||||
|
//上传文件日志
|
||||||
|
public static String UPLOAD_LOG = SYSTEM_PATH + "uploadLog.txt";
|
||||||
|
//写入日志
|
||||||
|
public static FileWriter writerLog = FileWriter.create(FileUtil.touch(UPLOAD_LOG), CharsetUtil.CHARSET_UTF_8);
|
||||||
|
//读日志
|
||||||
|
public static FileReader readerLog = new FileReader(UPLOAD_LOG);
|
||||||
|
//获取token
|
||||||
|
public final static String TOKEN_URL="https://websv.aliyundrive.com/token/refresh";
|
||||||
|
//文件列表
|
||||||
|
public final static String FILE_LIST_URL="https://api.aliyundrive.com/v2/file/list";
|
||||||
|
//文件上传
|
||||||
|
public final static String CREATE_FILE_URL="https://api.aliyundrive.com/v2/file/create";
|
||||||
|
//完成上传
|
||||||
|
public final static String COMPLETE_FILE_URL="https://api.aliyundrive.com/v2/file/complete";
|
||||||
|
//删除文件
|
||||||
|
public final static String DELETE_FILE_URL="https://api.aliyundrive.com/v2/recyclebin/trash";
|
||||||
|
public static String FILE_ID="";
|
||||||
|
//refresh_token
|
||||||
|
public static String REFRESH_TOKEN="";
|
||||||
|
//Token
|
||||||
|
public static String TOKEN="";
|
||||||
|
//driveId
|
||||||
|
public static String DriveId="";
|
||||||
|
//根目录
|
||||||
|
public final static String ROOT="root";
|
||||||
|
//上传目录
|
||||||
|
public static String PATH="";
|
||||||
|
//备份目录名称
|
||||||
|
public static String BACK_NAME="";
|
||||||
|
//备份目录名称
|
||||||
|
public static int BACK_TYPE=0;//0是普通备份 1是分类备份
|
||||||
|
//输出日志模式 0是覆盖 1追加
|
||||||
|
public static int CLEAN_CONSOLE=0;
|
||||||
|
//备份状态
|
||||||
|
public static boolean BACK_STATE = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加控制台日志
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
|
public static void addConsole(String text){
|
||||||
|
if (CLEAN_CONSOLE==0){
|
||||||
|
console.setText("开始运行"+"\n");
|
||||||
|
}else {
|
||||||
|
console.append("["+DateUtil.now()+"] "+text+"\n");
|
||||||
|
console.paintImmediately(console.getBounds());
|
||||||
|
scrollBar.setValue(scrollBar.getMaximum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.eg.www.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.eg.www.common.utils.AliYunPanUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 定时任务类
|
||||||
|
* Author: Eg
|
||||||
|
* Date: 2021/08/29
|
||||||
|
*/
|
||||||
|
public class CronTask {
|
||||||
|
|
||||||
|
//阿里云工具类
|
||||||
|
private AliYunPanUtil aliYunPanUtil=new AliYunPanUtil();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新阿里云盘token
|
||||||
|
*/
|
||||||
|
public void updateALiYunPanToken(){
|
||||||
|
if (StrUtil.isNotEmpty(CommonConstants.REFRESH_TOKEN)){
|
||||||
|
CommonConstants.addConsole("定时更新阿里云Token");
|
||||||
|
aliYunPanUtil.getAliYunPanInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时备份文件
|
||||||
|
*/
|
||||||
|
public void backFileList(){
|
||||||
|
try {
|
||||||
|
//执行上传文件操作
|
||||||
|
Thread backup = new Thread(() -> aliYunPanUtil.startBackup());
|
||||||
|
backup.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
CommonConstants.addConsole("遇到异常情况:"+e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.eg.www.common;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 模拟控制台类
|
||||||
|
* Author: Eg
|
||||||
|
* Date: 2021/08/29
|
||||||
|
*/
|
||||||
|
public class MyConsole extends JTextArea {
|
||||||
|
public MyConsole() {
|
||||||
|
String info="温馨提示:备份目录名称是要备份到阿里云盘那个目录下(不存在则自动创建)\n";
|
||||||
|
info+="普通备份:会按本地目录结构上传文件\n";
|
||||||
|
info+="分类备份:会将本地文件按文档、压缩包、软件、音乐、图片、视频等分类上传\n";
|
||||||
|
info+="运行日志...\n";
|
||||||
|
this.setText(info);
|
||||||
|
this.setForeground(Color.white);
|
||||||
|
this.setBackground(Color.BLACK);
|
||||||
|
//启动自动换行
|
||||||
|
this.setLineWrap(true);
|
||||||
|
//换行不断字
|
||||||
|
this.setWrapStyleWord(true);
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,178 @@
|
|||||||
|
package com.eg.www.common.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.digest.DigestUtil;
|
||||||
|
|
||||||
|
import javax.activation.MimetypesFileTypeMap;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 文件操作工具类
|
||||||
|
* Author: Eg
|
||||||
|
* Date: 2021/08/29
|
||||||
|
*/
|
||||||
|
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||||
|
|
||||||
|
public static final String FILE="File";//文件
|
||||||
|
public static final String FOLDER="Folder";//文件夹
|
||||||
|
static List<String> docTypes = new ArrayList<>();//文档类型
|
||||||
|
static List<String> compressTypes = new ArrayList<>();//压缩包类型
|
||||||
|
static List<String> imageTypes = new ArrayList<>();//图片类型
|
||||||
|
static List<String> musicTypes = new ArrayList<>();//音乐类型
|
||||||
|
static List<String> videoTypes = new ArrayList<>();//视频类型
|
||||||
|
static List<String> applyTypes = new ArrayList<>();//软件类型
|
||||||
|
static List<String> devTypes = new ArrayList<>();//开发类型
|
||||||
|
|
||||||
|
//文件类型
|
||||||
|
static {
|
||||||
|
/**
|
||||||
|
* 文档类型
|
||||||
|
*/
|
||||||
|
docTypes.add("xls");
|
||||||
|
docTypes.add("xlsx");
|
||||||
|
docTypes.add("xlsm");
|
||||||
|
docTypes.add("doc");
|
||||||
|
docTypes.add("docx");
|
||||||
|
docTypes.add("ppt");
|
||||||
|
docTypes.add("pptx");
|
||||||
|
docTypes.add("txt");
|
||||||
|
docTypes.add("pdf");
|
||||||
|
docTypes.add("chm");
|
||||||
|
docTypes.add("xmind");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩包类型
|
||||||
|
*/
|
||||||
|
compressTypes.add("zip");
|
||||||
|
compressTypes.add("rar");
|
||||||
|
compressTypes.add("7z");
|
||||||
|
compressTypes.add("tar.gz");
|
||||||
|
compressTypes.add("gz");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片类型
|
||||||
|
*/
|
||||||
|
imageTypes.add("png");
|
||||||
|
imageTypes.add("jpg");
|
||||||
|
imageTypes.add("jpeg");
|
||||||
|
imageTypes.add("gif");
|
||||||
|
imageTypes.add("ico");
|
||||||
|
imageTypes.add("psd");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 音频类型
|
||||||
|
*/
|
||||||
|
musicTypes.add("mp3");
|
||||||
|
musicTypes.add("wma");
|
||||||
|
musicTypes.add("aac");
|
||||||
|
musicTypes.add("m4a");
|
||||||
|
musicTypes.add("amr");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频类型
|
||||||
|
*/
|
||||||
|
videoTypes.add("mp4");
|
||||||
|
videoTypes.add("avi");
|
||||||
|
videoTypes.add("3gp");
|
||||||
|
videoTypes.add("flv");
|
||||||
|
videoTypes.add("mkv");
|
||||||
|
videoTypes.add("mov");
|
||||||
|
videoTypes.add("wmv");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 软件类型
|
||||||
|
*/
|
||||||
|
applyTypes.add("1");
|
||||||
|
applyTypes.add("apk");
|
||||||
|
applyTypes.add("exe");
|
||||||
|
applyTypes.add("ipa");
|
||||||
|
applyTypes.add("app");
|
||||||
|
applyTypes.add("dmg");
|
||||||
|
applyTypes.add("rpm");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开发类型
|
||||||
|
*/
|
||||||
|
devTypes.add("properties");
|
||||||
|
devTypes.add("java");
|
||||||
|
devTypes.add("php");
|
||||||
|
devTypes.add("jsp");
|
||||||
|
devTypes.add("js");
|
||||||
|
devTypes.add("vue");
|
||||||
|
devTypes.add("sh");
|
||||||
|
devTypes.add("sql");
|
||||||
|
devTypes.add("xml");
|
||||||
|
devTypes.add("html");
|
||||||
|
devTypes.add("conf");
|
||||||
|
devTypes.add("jar");
|
||||||
|
devTypes.add("bat");
|
||||||
|
devTypes.add("yml");
|
||||||
|
devTypes.add("css");
|
||||||
|
devTypes.add("json");
|
||||||
|
devTypes.add("out");
|
||||||
|
devTypes.add("class");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件类型
|
||||||
|
* @param name 文件名
|
||||||
|
* @return 返回文件类型
|
||||||
|
*/
|
||||||
|
public static String getFileTypes(String name){
|
||||||
|
//获取文件的后缀名
|
||||||
|
String suffix = getSuffix(name).toLowerCase();
|
||||||
|
if (docTypes.contains(suffix)) return "文档";
|
||||||
|
if (imageTypes.contains(suffix)) return "图片";
|
||||||
|
if (musicTypes.contains(suffix)) return "音频";
|
||||||
|
if (videoTypes.contains(suffix)) return "视频";
|
||||||
|
if (applyTypes.contains(suffix)) return "软件";
|
||||||
|
if (devTypes.contains(suffix)) return "开发";
|
||||||
|
if (compressTypes.contains(suffix)) return "压缩包";
|
||||||
|
return "其它";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取目录下的文件 或 文件夹
|
||||||
|
* 不含子目录
|
||||||
|
* @param path 目录绝对路径或者相对路径
|
||||||
|
* @param type 文件或文件夹 为空默认返回文件夹
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
public static List<String> fileFolderList(String path,String type) {
|
||||||
|
List<String> List = new ArrayList<>();
|
||||||
|
final File[] files = ls(path);
|
||||||
|
for (File file : files) {
|
||||||
|
if(FILE.equals(type) && file.isFile()){
|
||||||
|
List.add(file.getPath());
|
||||||
|
}
|
||||||
|
if (FOLDER.equals(type) && file.isDirectory()){
|
||||||
|
List.add(file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return List;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param path 文件路径
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> getFileInfo(String path) {
|
||||||
|
String contentType= new MimetypesFileTypeMap().getContentType(new File(path));
|
||||||
|
if (StrUtil.isEmpty(contentType)) contentType="application/octet-stream";
|
||||||
|
Map<String, Object> map = new HashMap();
|
||||||
|
File file = file(path);
|
||||||
|
String type = getFileTypes(file.getName());
|
||||||
|
map.put("name",file.getName());
|
||||||
|
map.put("path",file.getPath());
|
||||||
|
map.put("size",file.length());
|
||||||
|
map.put("type",type);
|
||||||
|
map.put("content_type",contentType);
|
||||||
|
map.put("content_hash",DigestUtil.sha1Hex(file).toUpperCase());
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.eg.www.common.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Eg
|
||||||
|
* @Date: 2021/8/29 17:50
|
||||||
|
*/
|
||||||
|
public class getToken {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#我是注释
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
#[com.eg.www]
|
||||||
|
#需要执行的类名和方法名
|
||||||
|
#App.Test = * * * * * ? *
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
[com.eg.www.common]
|
||||||
|
#每小时刷新阿里云盘登录信息
|
||||||
|
CronTask.updateALiYunPanToken = 0 0 0/1 * * ?
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
[com.eg.www.common]
|
||||||
|
#每天晚上八点自动备份文件
|
||||||
|
CronTask.backFileList = 0 0 20 * * ? *
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
#我是注释
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
#[com.eg.www]
|
||||||
|
#需要执行的类名和方法名
|
||||||
|
#App.Test = * * * * * ? *
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
[com.eg.www.common]
|
||||||
|
#每小时刷新阿里云盘登录信息
|
||||||
|
CronTask.updateALiYunPanToken = 0 0 0/1 * * ?
|
||||||
|
#执行的类或对象方法所在包的名字
|
||||||
|
[com.eg.www.common]
|
||||||
|
#每天晚上八点自动备份文件
|
||||||
|
CronTask.backFileList = 0 0 20 * * ? *
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,3 @@
|
|||||||
|
C:\Users\Administrator\Desktop\HKBTest\HKBTest.exe
|
||||||
|
C:\Users\Administrator\Desktop\HKBTest\Kbhk.dll
|
||||||
|
C:\Users\Administrator\Desktop\HKBTest\KE.ini
|
Loading…
Reference in New Issue