public static void main(String[] args) { // TODO Auto-generated method stub int j = 0; while(j<5) { File f = new File("c:/Mailboxes/in/"); File[] fArray = f.listFiles(); for(int i=0; i<fArray.length; i++) { if(fArray[i].getName().matches("[\\w]*.EML$")) { System.out.println(fArray[i].getName()); try { FileInputStream is = new FileInputStream(fArray[i]); byte[] b = new byte[(int)fArray[i].length()]; is.read(b); FileOutputStream os = new FileOutputStream("c:/mail/" + fArray[i].getName()); os.write(b); os.close(); is.close(); fArray[i].delete(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } j++; } }
扫描文件名称
最新推荐文章于 2021-08-07 23:58:24 发布