File 为什么我不能创建xlsx文件?

File 为什么我不能创建xlsx文件?,file,xlsx,File,Xlsx,错误是: public static void main(String []args)throws IOException { //FileInputStream file = new FileInputStream(new File("test.xlsx")); FileInputStream fis = new FileInputStream(new File("test.xlsx")); XSSFWorkbook workbook = new XSSFWorkboo

错误是:

public static void main(String []args)throws IOException
{
    //FileInputStream file = new FileInputStream(new File("test.xlsx"));
    FileInputStream fis = new FileInputStream(new File("test.xlsx"));
    XSSFWorkbook workbook = new XSSFWorkbook (fis);
    XSSFSheet sheet = workbook.getSheetAt(0);
    //Create First Row
    XSSFRow row1 = sheet.createRow(0);
    XSSFCell r1c1 = row1.createCell(0);
    r1c1.setCellValue("Emd Id");
    fis.close();
    try
    {
    FileOutputStream fos =new FileOutputStream(new File("test.xlsx"));
    workbook.write(fos);
    fos.close();
    System.out.println("Done");
    }
    catch(FileNotFoundException e)
    {
        e.printStackTrace();
    }
}
线程“main”java.io.FileNotFoundException:test.xlsx中的异常(系统找不到指定的文件) 在java.io.FileInputStream.open(本机方法) 位于java.io.FileInputStream。(未知源) 位于excel.CxssfWe1.main(CxssfWe1.java:25)
您正在尝试读取该行不存在的文件

Exception in thread "main" java.io.FileNotFoundException: test.xlsx (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at excel.CxssfWe1.main(CxssfWe1.java:25)

这正是错误消息所说的:“(系统找不到指定的文件)”

您需要发布一个特定的问题,而不仅仅是一堆代码。找不到您的输入文件。因此,您的程序将在以下行崩溃:
FileInputStream fis=newfileinputstream(新文件(“test.xlsx”)您是否确实阅读了错误消息?你知道,它们不是为了好玩才出现的。我是java开发新手。只是在学习阶段,在编写代码时遇到了这个问题。我可以创建HSSF工作簿,即xls工作簿,但不能创建xlsx工作簿。现在我该怎么问一个具体的问题,你能解释一下吗!是的,我读过。而我却不能把它做好!。我知道他们不仅仅是为了好玩。是的,阿尔宾。我明白了,但我的问题是。该怎么做才能做到这一点!首先确保文件存在,和/或将代码嵌入到try-catch块中。
FileInputStream fis = new FileInputStream(new File("test.xlsx"));