File dir = new File("crawl_html");
dir.mkdir();
String hash = MD5Util.md5Hex(url1.toString());
System.out.println("hash:-" + hash);
File file = new File(""+dir+"\""+hash+".txt");
最佳答案
java.io.File的构造函数之一采用父目录.你可以这样做:
原文链接:https://www.f2er.com/java/437554.htmlfinal File parentDir = new File("crawl_html");
parentDir.mkdir();
final String hash = "abc";
final String fileName = hash + ".txt";
final File file = new File(parentDir,fileName);
file.createNewFile(); // Creates file crawl_html/abc.txt