Java.Utils:文件重命名

Don’t say much, just go to the code.

package org.bood.common.utils;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

/**
 * 文件重命名
 *
 * @author bood
 * @since 2024/12/02
 */
public class FileRenamer {

    public static void main(String[] args) {
        // 替换为实际的目录路径
        String directoryPath = "path/to/your/directory";

        try {
            renameFilesInDirectory(directoryPath);
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            char targetChar = 'a';
            char replacementChar = 'b';
            replaceCharInFilenames(directoryPath, targetChar, replacementChar);
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            renameFilesByCreationTime(directoryPath);
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            organizeFilesByCreationYear(directoryPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 处理指定目录下的所有文件,先去掉文件名中的所有空格,然后在连字符 '-' 的前后加上空格。
     *
     * @param dirPath 要处理的目录路径
     * @author bood
     * @since 2024/12/02
     */
    public static void renameFilesInDirectory(String dirPath) throws IOException {
        Path dir = Paths.get(dirPath);

        // 检查路径是否存在且是一个目录
        if (!Files.exists(dir) || !Files.isDirectory(dir)) {
            throw new IllegalArgumentException("提供的路径不是一个有效的目录: " + dirPath);
        }

        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String originalFileName = file.getFileName().toString();
                String newFileName = modifyFileName(originalFileName);

                // 如果文件名没有改变,则跳过
                if (!originalFileName.equals(newFileName)) {
                    Path newFilePath = file.resolveSibling(newFileName);
                    // 重命名文件
                    Files.move(file, newFilePath, StandardCopyOption.REPLACE_EXISTING);
                    System.out.println("Renamed: " + originalFileName + " -> " + newFileName);
                }
                return FileVisitResult.CONTINUE;
            }

            private String modifyFileName(String fileName) {
                // 去掉文件名中的所有空格
                String noSpaces = fileName.replaceAll("\\s+", "");
                // 在连字符'-'的前后加上空格
                return noSpaces.replaceAll("(-)", " $1 ");
            }
        });
    }

    /**
     * 处理指定目录下的所有文件,将文件名中的指定字符替换为另一个字符。
     *
     * @param dirPath         要处理的目录路径
     * @param targetChar      要被替换的字符
     * @param replacementChar 用来替换的字符
     * @author bood
     * @since 2024/12/02
     */
    public static void replaceCharInFilenames(String dirPath, char targetChar, char replacementChar) throws IOException {
        Path dir = Paths.get(dirPath);

        // 检查路径是否存在且是一个目录
        if (!Files.exists(dir) || !Files.isDirectory(dir)) {
            throw new IllegalArgumentException("提供的路径不是一个有效的目录: " + dirPath);
        }

        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String originalFileName = file.getFileName().toString();
                String newFileName = modifyFileName(originalFileName, targetChar, replacementChar);

                // 如果文件名没有改变,则跳过
                if (!originalFileName.equals(newFileName)) {
                    Path newFilePath = file.resolveSibling(newFileName);
                    // 重命名文件
                    Files.move(file, newFilePath, StandardCopyOption.REPLACE_EXISTING);
                    System.out.println("Renamed: " + originalFileName + " -> " + newFileName);
                }
                return FileVisitResult.CONTINUE;
            }

            private String modifyFileName(String fileName, char targetChar, char replacementChar) {
                // 将文件名中的目标字符替换为替代字符
                return fileName.replace(targetChar, replacementChar);
            }
        });
    }

    /**
     * 处理指定目录下的所有文件,将文件名按文件的创建时间命名。
     *
     * @param dirPath 要处理的目录路径
     * @author bood
     * @since 2024/12/02
     */
    public static void renameFilesByCreationTime(String dirPath) throws IOException {
        Path dir = Paths.get(dirPath);

        // 检查路径是否存在且是一个目录
        if (!Files.exists(dir) || !Files.isDirectory(dir)) {
            throw new IllegalArgumentException("提供的路径不是一个有效的目录: " + dirPath);
        }

        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                try {
                    // 获取文件的基本属性
                    BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class);
                    FileTime creationTime = attributes.creationTime();

                    // 将文件创建时间转换为字符串格式
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
                    String timeString = sdf.format(new Date(creationTime.toMillis()));

                    // 构造新的文件名:创建时间 + 原始文件扩展名(如果有)
                    String originalFileName = file.getFileName().toString();
                    String extension = "";
                    int dotIndex = originalFileName.lastIndexOf('.');
                    if (dotIndex != -1) {
                        extension = originalFileName.substring(dotIndex);
                    }
                    String newFileName = timeString + extension;

                    // 如果文件名没有改变,则跳过
                    if (!originalFileName.equals(newFileName)) {
                        Path newFilePath = file.resolveSibling(newFileName);
                        // 重命名文件
                        Files.move(file, newFilePath, StandardCopyOption.REPLACE_EXISTING);
                        System.out.println("Renamed: " + originalFileName + " -> " + newFileName);
                    }
                } catch (IOException e) {
                    System.err.println("Failed to rename file: " + file + ". Reason: " + e.getMessage());
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }

    /**
     * 处理指定目录下的所有文件,按文件的创建年份归纳到相应的子文件夹下。
     *
     * @param dirPath 要处理的目录路径
     * @author bood
     * @since 2024/12/02
     */
    public static void organizeFilesByCreationYear(String dirPath) throws IOException {
        Path dir = Paths.get(dirPath);

        // 检查路径是否存在且是一个目录
        if (!Files.exists(dir) || !Files.isDirectory(dir)) {
            throw new IllegalArgumentException("提供的路径不是一个有效的目录: " + dirPath);
        }

        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                try {
                    // 获取文件的基本属性
                    BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class);
                    FileTime creationTime = attributes.creationTime();

                    // 将文件创建时间转换为LocalDate
                    Instant instant = creationTime.toInstant();
                    LocalDate date = instant.atZone(ZoneId.systemDefault()).toLocalDate();
                    int year = date.getYear();

                    // 构造目标年份文件夹路径
                    Path yearDir = dir.resolve(Integer.toString(year));

                    // 如果年份文件夹不存在,则创建它
                    if (!Files.exists(yearDir)) {
                        Files.createDirectories(yearDir);
                        System.out.println("Created directory: " + yearDir);
                    }

                    // 移动文件到对应的年份文件夹
                    Path targetFilePath = yearDir.resolve(file.getFileName());
                    if (!file.equals(targetFilePath)) {
                        Files.move(file, targetFilePath, StandardCopyOption.REPLACE_EXISTING);
                        System.out.println("Moved: " + file + " -> " + targetFilePath);
                    }
                } catch (IOException e) {
                    System.err.println("Failed to move file: " + file + ". Reason: " + e.getMessage());
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }

}
!ENTRY org.eclipse.core.resources 2 10035 2025-12-24 16:20:04.645 !MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes. !ENTRY org.eclipse.osgi 4 0 2025-12-24 16:20:04.680 !MESSAGE An error occurred while automatically activating bundle org.eclipse.core.resources (54). !STACK 0 org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources. at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:854) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:775) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1057) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:387) at org.eclipse.osgi.container.Module.doStart(Module.java:639) at org.eclipse.osgi.container.Module.start(Module.java:498) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:528) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:122) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:620) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:348) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:516) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:434) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:174) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at org.jkiss.dbeaver.core.DesktopPlatform.initialize(DesktopPlatform.java:136) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jkiss.dbeaver.utils.RuntimeUtils.injectComponentReferences(RuntimeUtils.java:708) at org.jkiss.dbeaver.utils.RuntimeUtils.getBundleService(RuntimeUtils.java:680) at org.jkiss.dbeaver.runtime.DBWorkbench.getApplicationWorkbench(DBWorkbench.java:45) at org.jkiss.dbeaver.runtime.DBWorkbench.getPlatform(DBWorkbench.java:51) at org.jkiss.dbeaver.utils.SystemVariablesResolver.getWorkspacePath(SystemVariablesResolver.java:99) at org.jkiss.dbeaver.utils.SystemVariablesResolver.get(SystemVariablesResolver.java:66) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:553) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:526) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.initDebugWriter(DBeaverApplication.java:728) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.start(DBeaverApplication.java:243) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jkiss.dbeaver.launcher.DBeaverLauncher.invokeFramework(DBeaverLauncher.java:650) at org.jkiss.dbeaver.launcher.DBeaverLauncher.basicRun(DBeaverLauncher.java:610) at org.jkiss.dbeaver.launcher.DBeaverLauncher.run(DBeaverLauncher.java:1461) Caused by: org.eclipse.core.internal.dtree.ObjectNotFoundException: Tree element '/General/Scripts/mes/Utils.sql' not found. at org.eclipse.core.internal.dtree.AbstractDataTree.handleNotFound(AbstractDataTree.java:183) at org.eclipse.core.internal.dtree.DeltaDataTree.getData(DeltaDataTree.java:572) at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:54) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:51) at org.eclipse.core.internal.dtree.DeltaDataTree.asBackwardDelta(DeltaDataTree.java:96) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:809) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:785) at org.eclipse.core.internal.watson.ElementTree.immutable(ElementTree.java:540) at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:797) at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1616) at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2618) at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2319) at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:591) at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:1) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:947) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:257) at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:184) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:324) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:267) at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:565) at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:833) at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:825) ... 42 more Root exception: org.eclipse.core.internal.dtree.ObjectNotFoundException: Tree element '/General/Scripts/mes/Utils.sql' not found. at org.eclipse.core.internal.dtree.AbstractDataTree.handleNotFound(AbstractDataTree.java:183) at org.eclipse.core.internal.dtree.DeltaDataTree.getData(DeltaDataTree.java:572) at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:54) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.NoDataDeltaNode.asBackwardDelta(NoDataDeltaNode.java:63) at org.eclipse.core.internal.dtree.DataDeltaNode.asBackwardDelta(DataDeltaNode.java:51) at org.eclipse.core.internal.dtree.DeltaDataTree.asBackwardDelta(DeltaDataTree.java:96) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:809) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:808) at org.eclipse.core.internal.dtree.DeltaDataTree.reroot(DeltaDataTree.java:785) at org.eclipse.core.internal.watson.ElementTree.immutable(ElementTree.java:540) at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:797) at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1616) at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2618) at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2319) at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:591) at org.eclipse.core.resources.ResourcesPlugin$WorkspaceInitCustomizer.addingService(ResourcesPlugin.java:1) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:947) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:257) at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:184) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:324) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:267) at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:565) at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:833) at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:825) at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:775) at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1057) at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:387) at org.eclipse.osgi.container.Module.doStart(Module.java:639) at org.eclipse.osgi.container.Module.start(Module.java:498) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:528) at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:122) at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:620) at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:348) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:414) at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41) at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:516) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:434) at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:174) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at org.jkiss.dbeaver.core.DesktopPlatform.initialize(DesktopPlatform.java:136) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jkiss.dbeaver.utils.RuntimeUtils.injectComponentReferences(RuntimeUtils.java:708) at org.jkiss.dbeaver.utils.RuntimeUtils.getBundleService(RuntimeUtils.java:680) at org.jkiss.dbeaver.runtime.DBWorkbench.getApplicationWorkbench(DBWorkbench.java:45) at org.jkiss.dbeaver.runtime.DBWorkbench.getPlatform(DBWorkbench.java:51) at org.jkiss.dbeaver.utils.SystemVariablesResolver.getWorkspacePath(SystemVariablesResolver.java:99) at org.jkiss.dbeaver.utils.SystemVariablesResolver.get(SystemVariablesResolver.java:66) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:553) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:526) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.initDebugWriter(DBeaverApplication.java:728) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.start(DBeaverApplication.java:243) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jkiss.dbeaver.launcher.DBeaverLauncher.invokeFramework(DBeaverLauncher.java:650) at org.jkiss.dbeaver.launcher.DBeaverLauncher.basicRun(DBeaverLauncher.java:610) at org.jkiss.dbeaver.launcher.DBeaverLauncher.run(DBeaverLauncher.java:1461) !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:04.700 !MESSAGE Error matching regex !SUBENTRY 1 org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:04.700 !MESSAGE Cannot invoke "org.jkiss.dbeaver.model.app.DBPWorkspace.getAbsolutePath()" because the return value of "org.jkiss.dbeaver.model.app.DBPPlatform.getWorkspace()" is null !STACK 0 java.lang.NullPointerException: Cannot invoke "org.jkiss.dbeaver.model.app.DBPWorkspace.getAbsolutePath()" because the return value of "org.jkiss.dbeaver.model.app.DBPPlatform.getWorkspace()" is null at org.jkiss.dbeaver.utils.SystemVariablesResolver.getWorkspacePath(SystemVariablesResolver.java:99) at org.jkiss.dbeaver.utils.SystemVariablesResolver.get(SystemVariablesResolver.java:66) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:553) at org.jkiss.dbeaver.utils.GeneralUtils.replaceVariables(GeneralUtils.java:526) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.initDebugWriter(DBeaverApplication.java:728) at org.jkiss.dbeaver.ui.app.standalone.DBeaverApplication.start(DBeaverApplication.java:243) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jkiss.dbeaver.launcher.DBeaverLauncher.invokeFramework(DBeaverLauncher.java:650) at org.jkiss.dbeaver.launcher.DBeaverLauncher.basicRun(DBeaverLauncher.java:610) at org.jkiss.dbeaver.launcher.DBeaverLauncher.run(DBeaverLauncher.java:1461) !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:04.729 !MESSAGE Metadata is read before workspace initialization !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:04.808 !MESSAGE Metadata is read before workspace initialization !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:04.866 !MESSAGE Metadata is read before workspace initialization !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:05.896 !MESSAGE Metadata is read before workspace initialization !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:06.306 !MESSAGE Metadata is read before workspace initialization !ENTRY org.jkiss.dbeaver.model 2 0 2025-12-24 16:20:06.337 !MESSAGE Metadata is read before workspace initialization !SESSION 2025-12-24 16:20:11.117 ----------------------------------------------- eclipse.buildId=unknown java.version=17.0.6 java.vendor=Eclipse Adoptium BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh Framework arguments: -eclipse.keyring C:\Users\王建伟\AppData\Roaming\DBeaverData\secure\secure_storage Command-line arguments: -os win32 -ws win32 -arch x86_64 !ENTRY org.eclipse.core.resources 2 10035 2025-12-24 16:20:12.411 !MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
最新发布
12-25
08-24 13:50:42.860120 18491 18491 W BootstrapClass: reflect bootstrap failed: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at org.hapjs.common.utils.hiddenapi.BootstrapClass.<clinit>(SourceFile:79) at org.hapjs.common.utils.hiddenapi.Reflection.unseal(SourceFile:20) at org.hapjs.common.utils.hiddenapi.Reflection.invoke(SourceFile:9) at com.nearme.instant.platform.Application.attachBaseContext(SourceFile:45) at android.app.Application.attach(Application.java:368) at android.app.Instrumentation.newApplication(Instrumentation.java:1368) at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1566) at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1479) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8574) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2792) at android.os.Handler.dispatchMessage(Handler.java:115) at android.os.Looper.loopOnce(Looper.java:298) at android.os.Looper.loop(Looper.java:408) at android.app.ActivityThread.main(ActivityThread.java:9952) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:613) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1074) Caused by: java.lang.NoSuchMethodException: dalvik.system.VMRuntime.setHiddenApiExemptions [class [Ljava.lang.String;] at java.lang.Class.getMethod(Class.java:2940) at java.lang.Class.getDeclaredMethod(Class.java:2919)
08-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值