JAVA開発メモ
Commons-IO のバックアップ(No.4)
 

[トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]


try { InputStream in = new FileInputStream("C:\\tmp\\org.txt"); OutputStream out = new FileOutputStream("C:\\tmp\\copy.txt"); CopyUtils.copy(in, out); } catch (Exception e) { e.printStackTrace(); } InputStream in = null; try { in = new URL("http://www.moriwaki.net/wiki/").openStream(); System.out.println(IOUtils.toString(in)); } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(in); } File dir = new File("C:\\tmp\\work"); try { FileUtils.cleanDirectory(dir); } catch (IOException e) { e.printStackTrace(); } File file1 = new File("C:\\tmp\\test.txt"); File file2 = new File("C:\\tmp\\copy.txt"); try { FileUtils.copyFile(file1, file2); } catch (IOException e) { e.printStackTrace(); } File dir = new File("C:\\tmp"); String[] extensions = {"txt", "html"}; Collection files = FileUtils.listFiles(dir, extensions, recursive); System.out.println(files); File dir = new File("C:\\tmp"); long size = FileUtils.sizeOfDirectory(dir); System.out.println(size + " bytes"); System.out.println(FileUtils.byteCountToDisplaySize(size)); 693928711 bytes 661 MB File dir = new File("C:\\tmp"); IOFileFilter fileFilter1 = FileFilterUtils.prefixFileFilter("test"); IOFileFilter fileFilter2 = FileFilterUtils.suffixFileFilter("html"); IOFileFilter fileFilter = FileFilterUtils.andFileFilter(fileFilter1, fileFilter2); IOFileFilter dirFilter = FileFilterUtils.trueFileFilter(); dirFilter = FileFilterUtils.makeCVSAware(dirFilter); files = FileUtils.listFiles(dir, fileFilter, dirFilter); System.out.println(files); [C:\tmp\test.html, C:\tmp\test2.html]
トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.28

HTML convert time to 0.011 sec.