- Ingat nama file sama dengan nama class, jadi berdasarkan kode dibawah anda sudah tau pasti harus apa...
- jika masih tidak tau harus apa, silahkan komentar di post ini...
--------------------------------------------------------------------------------------------------------------------------
import java.io.File;
class demobuatdir{
public static void main (String[]args){
File f = new File("NewDir/dir");
f.mkdirs();
}}
public static void main (String[]args){
File f = new File("NewDir/dir");
f.mkdirs();
}}
import java.io.*;
class demobuatfil{
public static void main(String [] args) throws IOException{
File f = new File("NewDir/sample.txt");
f.createNewFile();
}}
public static void main(String [] args) throws IOException{
File f = new File("NewDir/sample.txt");
f.createNewFile();
}}
import java.io.File;
class demohapusfil{
public static void main(String [] args) {
File f = new File("NewDir/contoh.txt");
f.delete();
}}
public static void main(String [] args) {
File f = new File("NewDir/contoh.txt");
f.delete();
}}
import java.io.File;
class demoubahfil{
public static void main(String [] args) {
File f = new File("NewDir/sample.txt");
f.renameTo(new File("NewDir/contoh.txt"));
}}
public static void main(String [] args) {
File f = new File("NewDir/sample.txt");
f.renameTo(new File("NewDir/contoh.txt"));
}}
Tidak ada komentar:
Posting Komentar