Java 将我的文件复制到目录时出现问题

Java 将我的文件复制到目录时出现问题,java,directory,java-io,Java,Directory,Java Io,我在将文件复制到目录时遇到问题 这是我写的代码 package icecream1; import java.nio.file.Paths; /** * * @author */ public class Icecream1 { /** * @param args the command line arguments */ public static void main(String[] args) { try {

我在将文件复制到目录时遇到问题

这是我写的代码

package icecream1;

import java.nio.file.Paths;

/**
 *
 * @author
 */
public class Icecream1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {

            TextIO.readFile("icecream.txt"); // open file
            System.out.println("Please make sure the file is present before");

            System.out.println("running the program.");

            System.exit(1); // Terminates the program.

        }

        catch (IllegalArgumentException e) {

            System.out.println("Can't open file \"icecream.txt\" for reading!");

        }

        int numberCones = 1; // stores total number of cones

        int numberStrawberry = 1; // stores total number of strawberry cones

        double percent;

        while (TextIO.eof()) { // read one line

            String data; // stores icecream flavor

            data = TextIO.getln(); // read a line

            numberCones += 1; // increment count

            if (data.equals("Strawberry"))

                numberStrawberry += 1;

        } // while

//calculate percent of strawberry icecream

        percent = 100.0 * numberStrawberry / numberCones;

//display result    
        String ourDirectory = Paths.get(".").toAbsolutePath().normalize().toString();

        TextIO.readFile(ourDirectory + "//dist//icecream.txt");

        System.out.println(TextIO.getlnString());

        System.out.println("The total Number of cones: " + numberCones);

        System.out.println("The total Number of Strawberry cones: " + numberStrawberry);

        System.out.println("The total Percentage of Strawberry cones: " + percent + " %");
        // TODO code application logic here
    }

}


无法打开文件“icecream.txt”进行阅读

欢迎来到StackOverflow!要格式化您的文章并使其更易于阅读,请尝试将代码放在三个背景标记之间-请参阅链接以获取示例。这使得回答您的问题更容易。欢迎使用StackOverflow!要格式化您的文章并使其更易于阅读,请尝试将代码放在三个背景标记之间-请参阅链接以获取示例。这使得回答你的问题更容易。
package icecream1;

import java.nio.file.Paths;

/**
 *
 * @author
 */
public class Icecream1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {

            TextIO.readFile("icecream.txt"); // open file
            System.out.println("Please make sure the file is present before");

            System.out.println("running the program.");

            System.exit(1); // Terminates the program.

        }

        catch (IllegalArgumentException e) {

            System.out.println("Can't open file \"icecream.txt\" for reading!");

        }

        int numberCones = 1; // stores total number of cones

        int numberStrawberry = 1; // stores total number of strawberry cones

        double percent;

        while (TextIO.eof()) { // read one line

            String data; // stores icecream flavor

            data = TextIO.getln(); // read a line

            numberCones += 1; // increment count

            if (data.equals("Strawberry"))

                numberStrawberry += 1;

        } // while

        //calculate percent of strawberry icecream

        percent = 100.0 * numberStrawberry / numberCones;

        //display result    
        String ourDirectory = Paths.get(".").toAbsolutePath().normalize().toString();

        TextIO.readFile(ourDirectory + "//dist//icecream.txt");

        System.out.println(TextIO.getlnString());
        System.out.println("The total Number of cones: " + numberCones);
        System.out.println("The total Number of Strawberry cones: " + numberStrawberry);
        System.out.println("The total Percentage of Strawberry cones: " + percent + " %");
        // TODO code application logic here
    }
}