首页 > 解决方案 > 似乎它没有将值传递给参数 [Java]

问题描述

我的代码是这样的。它总是返回 0 或 null;

在我的Encryptor Class

public void encrypt(File src, File dst) throws IOException {
    if (!dst.exists()) {
        dst.mkdir();
    }
    if (!dst.isDirectory()) {
        return;
    }

    try {
        if (!src.isDirectory()) {
            copyEncrypted(src, dst);
        } else {
            File[] files = src.listFiles();
            System.out.println("Encrypting...");
            for (File f : files) {
                copyEncrypted(f, dst);
                if (deleteOriginal) {
                    f.delete();
                }
            }
            InterfaceController ic = new InterfaceController();
            ic.fileList(files.length);
            //ic._notif.setText("GAGO");
            for (File file : files) {
                System.out.println(file);
            }
            //System.out.println(files.length + " files are encrypted");
        }
    } catch (IOException e) {
        throw e;
    }
}

在我InterfaceController Class用一个方法fileList和一个 int 参数

private int fileListMain = 0
public void fileList(int List) {
    fileListMain = List;
    //_notif.setText(fileListMain + " files are encrypted successfully!");
}

就是这样了。每当我运行 Main 并尝试打印文件的大小时。它总是返回 0,当我试图删除 fileListMain 变量的值时,它返回 null。请帮我摆脱这个。提前谢谢你!这是我在stackoverflow中的第一个查询。:)

标签: javanullpointerexceptionnull

解决方案


推荐阅读