"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0." 同时使用 FileWriter Class 输出 Java 中的文件

"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0." while using FileWriter Class to output the file in Java

我尝试编写一个 FileWriter 来输出我的文件。

public class TestWriter{
    public static void main(String[] args){
        FileWriter fw = new FileWriter("\User\Eric\Desktop\writer.txt"); //absolute position
            fw.write("testing");           //write some content in my text file
            fw.flush();                    //force to output the source from buffer zone
            fw.close();                    //close the IOstream and release the source
    }
}

结果是

"Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0."

我试过降低我的 gradle 版本,但还是没用。 很抱歉问这个基本问题,非常感谢能解决我问题的人。

这是我的 gradle 文档

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.10'
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    mavenCentral()
}


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api

}

test {
    useJUnitPlatform()
}

我终于找到了 problem.I 使用 ./gradlew lint --warning-mode fail 来验证程序并返回失败说 FAILURE: Build failed with an exception. 所以我的绝对路径可能是 wrong.The 原因代码不' 工作是因为绝对路径形式是无效的。 在 Windows 环境中,我们使用“\”来分隔 IntelliJ 中文件夹之间的文件夹。前任。 D:\Documents\course\practice.txt 另一方面,在 Mac 环境中,您无需更改 path.ex./Users/Eric/Desktop/writer.txt 中的任何内容,它会起作用

尝试gradle --version并与./gradlew wrapper --version进行比较;也许您需要降级的是 gradle-wrapper 而不是 gradle 本身。


但是,这只是一个警告,表明您的代码或某些依赖项正在使用某些 Gradle 已弃用的功能。

这本身并不是错误。

弃用只是一个警告,关于需要更新当前 运行 代码以便能够在 Gradle 8.0 API 发布时升级。
只有在那个时候你才会被迫解决问题。

你可以暂时忽略它。但不要忘记它。