<dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-io</artifactId> <version>3.3.0</version> </dependency> File inputFile = new File("input.txt"); File outputFile = new File("output.txt"); try { FileUtils.copyFile(inputFile, outputFile); } catch (IOException e) { } File file = new File("file.txt"); if (file.exists()) { try { FileUtils.forceDelete(file); } catch (IOException e) { } } else { } File sourceDirectory = new File("source"); File targetDirectory = new File("target"); try { FileUtils.copyDirectory(sourceDirectory, targetDirectory); } catch (IOException e) { } String filePath = "C:\\path\\to\\file.txt"; File file = PlexusIoResourceUtils.resolveFile(filePath); System.out.println(file.getAbsolutePath()); String directoryPath = "C:\\path\\to\\directory"; File directory = PlexusIoResourceUtils.resolveFile(directoryPath); System.out.println(directory.getAbsolutePath()); String url = "http://example.com/example.txt"; File output = new File("output.txt"); try { URL sourceUrl = new URL(url); FileUtils.copyURLToFile(sourceUrl, output); } catch (IOException e) { } String url = "http://example.com/example.txt"; try { URL sourceUrl = new URL(url); String content = IOUtil.toString(sourceUrl.openStream(), "UTF-8"); } catch (IOException e) { }


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