import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class z31 {
File directory;
public static void main(String[] args) {
try {
z31 z = new z31();
z.directory = new File("/Users/eunsukkim/Desktop/copy2");
File newfile = new File("/Users/eunsukkim/Desktop/kkk.txt");
if(!z.directory.exists()){
z.directory.mkdir();
}
if(!newfile.exists()){
newfile.createNewFile();
}
String zz = "나는시발\n머하는거냐";
Path path = Paths.get("/Users/eunsukkim/Desktop/kkk.txt");
Files.writeString(path,zz,StandardCharsets.UTF_8);
System.out.println(Files.probeContentType(path));
System.out.println(Files.size(path));
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
String content = Files.readString(path,Charset.defaultCharset());
System.out.println(content);
File dir = new File("/Users/eunsukkim/Desktop");
File deletefile = new File("/Users/eunsukkim/Desktop/kkk.txt");
File[] filearr = dir.listFiles();
for(File f : filearr){
System.out.println(f.getName());
}
z.directory.delete();
boolean isdeleted = deletefile.delete();
if(isdeleted){
System.out.println("지워짐");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
댓글 영역