<dependency> <groupId>com.tkscommon</groupId> <artifactId>tkscommons</artifactId> <version>1.0.0</version> </dependency> String content = FileUtils.readFileToString(new File("path/to/file.txt"), StandardCharsets.UTF_8); FileUtils.writeStringToFile(new File("path/to/file.txt"), "Hello, TksCommons!", StandardCharsets.UTF_8); FileUtils.copyFile(new File("path/to/source.txt"), new File("path/to/destination.txt")); FileUtils.deleteQuietly(new File("path/to/file.txt")); try (InputStream is = IOUtils.toInputStream("file content", StandardCharsets.UTF_8)) { } try (OutputStream os = new FileOutputStream(new File("path/to/file.txt"))) { IOUtils.write("Hello, TksCommons!", os, StandardCharsets.UTF_8); } File directory = new File("path/to/directory"); Collection<File> files = FileUtils.listFiles(directory, null, true); for (File file : files) { System.out.println(file.getAbsolutePath()); }


上一篇:
下一篇:
切换中文