-1
try
        {            
            PdfReader reader = new PdfReader(RESULT1);
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT2));
            AcroFields form = stamper.getAcroFields();
            String name = form.getField("Text1");//Check Box 1  
            stamper.close();
            reader.close();

            FileInputStream file = new FileInputStream(new File("//Users//"+ usr +"//Desktop//TNA//input//FR-OPS-030 Master Training Plan_Rev4.xls"));
            HSSFWorkbook workbook = new HSSFWorkbook(file);
            HSSFSheet sheet = workbook.getSheet("Sheet1");//    getSheetAt(0);

            HSSFRow row = sheet.createRow((short) 0);    
            HSSFCellStyle style = workbook.createCellStyle();
            style.setFillForegroundColor(HSSFColor.DARK_BLUE.index);
            style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

            HSSFRow row1 = sheet.createRow(7);
            HSSFCell name_c1 = row1.createCell(0);
            name_c1.setCellValue(name);
            name_c1.setCellStyle(style);

            file.close();

            FileOutputStream outFile =new FileOutputStream(new File("//Users//"+ usr +"//Desktop//TNA//output//FR-OPS-030 Master Training Plan_Rev41w.xls"));
            workbook.write(outFile);
            outFile.close();
        }
        catch(Exception ex)
        {
           System.out.println(ex);                
        }

我使用代码从文件夹中读取 PDF 文件。它适用于单个文档,但我在文件夹中有多个文件。如何阅读 PDF 多个文件。请指教

4

1 回答 1

3

你可以先看看java.io.File哪些有列出文件的方法......

或者,如果您使用的是 Java 7+,您可以查看增强的文件 I/O API

于 2013-12-19T03:15:24.720 回答