區(qū)別:
mkdir
和mkdirs
:mkdir只能用來(lái)創(chuàng)建文件夾,且只能創(chuàng)建一級(jí)目錄;
mkdirs同樣只能用來(lái)創(chuàng)建文件夾,可創(chuàng)建多級(jí)目錄 ,如果上級(jí)不存在,就會(huì)自動(dòng)創(chuàng)建。
createNewFile
:只能用來(lái)創(chuàng)建文件,且只能在已存在的目錄下創(chuàng)建文件。
一般情況下配合使用,附上一段代碼,會(huì)在自定義的目錄下創(chuàng)建名為111的docx文件,將inputString字符串內(nèi)容寫(xiě)入其中。
想學(xué)習(xí)java么,這里有免費(fèi)視頻教程:java教學(xué)視頻
示例演示如下:
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Modify { public static void main(String[] args) throws IOException { String path = "F:\\Users\\yyy\\Desktop\\111.docx"; Modify modify = new Modify(); modify.create("hhh",path); } /** * * @param inputString 需寫(xiě)入的字符串內(nèi)容 * @param path 文件創(chuàng)建的路徑 * @throws IOException */ private void create(String inputString,String path) throws IOException { String newPath = path.substring(0,path.lastIndexOf("\\")); File file = new File(newPath); if (!file.exists()){ file.mkdirs(); } File newFile = new File(path); if (!newFile.exists()){ newFile.createNewFile(); } ByteArrayInputStream input = new ByteArrayInputStream(inputString.getBytes()); int index; byte[] bytes = new byte[1024]; FileOutputStream fs = new FileOutputStream(path); while ((index = input.read(bytes)) != -1) { fs.write(bytes, 0, index); fs.flush(); } fs.close(); input.close(); } }
大家都在查看的教程:java編程入門(mén)
? ??? Java?? ??? ???? ??? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JDBC ????? ???? ????? ?? ?? ?? ??? ?? ?? ??? ?? ? ?? ??? ?? ?? ?? ??? ???????. 1. ????? ????? Conn.SetAutoCommit (False)?? ??????. 2. ??? ? ????? ?? ?? SQL ??? ?????. 3. ?? ??? ??? ?? Conn.commit ()?? ???? ??? ???? ???? ?? ??? ???? Conn.Rollback ()?? ??????. ???, ? ??? ???? ????, ??? ???? ????, ?? ??? ??? ?? ??? ??? ???? ? ???????. ?? ?? ?? ???? ????? ??? ???? ?? ?? ???? ???? ??? ????? ?? ??? ??? ? ?? ???? ?? ????.

Pre-FormancetArtUptimeMoryUsage, Quarkusandmicronautleadduetocompile-timeprocessingandgraalvsupport, withquarkusoftenperforminglightbetterine serverless sinarios.2.thyvelopecosyste,

Java 's Garbage Collection (GC)? ???? ???? ???? ??????, ?? ? ??? ??? ? ??? ??? ??? ??? ????. 1.GC? ?? ?? (? : ?? ??, ?? ???, ?? ?? ?)?? ??? ???? ????, ?? ? ??? ??? ???? ?????. 2. ?? ???? ????? ????, ?? ?? ??? ??? ???? ?? ??? ??????. 3. ?? ?? ?? ?? : ??? ?? (Eden, S0, S1)? ?? ????? ?????. ??? ??? ?? ? MajorGC? ???? ? ??? ? ????. Metaspace? ??? ?? ???? ?????. 4. JVM? ??? GC ??? ?????. SerialGC? ??? ?? ????? ?????. ParallelGC? ???? ??????. CMS? ?? ???

??? htmlinput ??? ???? ??? ???? ????? ??? ??? ?? ??? ???? ???? ? ????. 1. ???, ???, ??, ?? ? ??? ?? ??? ??? ?? ?? ?? ??? ???? ???? ??? ? ???? ??? ? ????. 2. HTML5? ?????? ??? ? ?? ?? ??? ?? ? ??? URL, ??, ?? ? ??? ?? ??? ??? ??????. 3. ?? ?? ? ? ??? ??? ???? ?? ??? ???? ???? ?? ???? ?? ???? ???? ?? ? ? ??? ?? ???????.

GradleisBetTerChoiceFormostNewProjectSduetoitssuperiorflexible, Performance, and ModernToolingsupport.1.Gradle'Sgroovy/kotlindslismoreConcisENDEXPRESSIVETHANMAVEN'SVOSEXML.2.GradleOutsMaveninbuildweedweedweedweedweedweedweedweedweedweedweedweedweedweede

GO? HTTP ?? ????? ?? ??, ??, ????? IP ? ?? ??? ?? ? ? ????. 1. http.handlerfunc? ???? ????? ????, 2. ??? ???? ?? ?? ??? ?? ??? ??????. ?? ?? ??? ???? ??? ?????? ??? ????? ???? ? ?????. ?? ???? ?? ?? ??, JSON ?? ?? ? ?? ID ??? ?????.

? ??? ?? ??? ??? ??? ?? ??? ?????? ???? ??? ??? ???? ?? ???? ????. 1. Java? ?? ???? ???? ????? ??? ???? ?? ?????? ???? ?????. 2. ?? ?? ??? ?? ??? ?????? ???? ???, ??? ??? ??? ???? ??? ?? ? ? ?? ????? ????. 3. ??? ???? ?? ???? ????? ?? Lambda ??? ?? ??? ? ????. 4. GUI ?? Javabean ????? ?? PropertyChangelistener? ??? ? ????. ??? ??? ????? ??-??, ????? ?? ?? Java? ??? ?? ??? ????? ??? ???????.

ExecutorService? I/O ?? ?? ??? ??? ?? ??? ? ??? ??? ??? ?????. ??? ?? ???? ???? ????, ??? ?? ?? ?? ?? ?? ??? ??? ????, ?? ??? ????. ?? ???? ?????? ???? ??? ?? ?? ??? ?????. 2. Fork/Join ??? ??? ?? ? ???? CPU ??? ? ??? ?? ??????, ???? ? ?? ?? ? ?? ???? ????? ???? ? ?? ask ?? ?? ??? ?? ???? ?? ??? ?????. ? ?? ?? ? ?? ????? ?????. ?? ??? ??? ?? ?? ?? ?? ????? ???????. 3. ?? ?? : ??
