Please enable JavaScript.
Coggle requires JavaScript to display documents.
FAJLOVI/FOLDERI (PUTANJE (APSOLUTNA PUTANJA (Putanja do nekog file/foldera…
FAJLOVI/FOLDERI
FILE SISTEM
Hijerarhijska organizacija fileova i direktorijuma, počevši od root direktorijuma
PAKET
java.io
KLASA
FIle
-
OSNOVNE METODE
-
getName();
prikazuje ime filea
- 1 more item...
-
-
-
-
PUTANJE
-
RELATIVNA PUTANJA
Ne zahteva navođenje root direktorijuma, već se navodi onaj folder u kojem se već nalazimo
-
-
KREIRANJE FOLDERA
METODA
mkdir();
public static void main (String[]args){File testDirectory = new File ("C:\test"); try { if(!testDirectory.exists())}testDirectory.mkdir(); else System.out.println("Test directory already exists.")}catch(Exceptoon e)
-
KOPIRANJE SADRŽAJA
METODA
-
PAKET
java.nio.
KLASA
Files
public static void main(String [] args){ Path source = Paths.get("C:\test\text.txt"); Path destination = Path.get("D:\text.txt); try { if(!Files.exists(source) Szstem.out.println("File doesn't exist."); return; if(!Files.exists(destination.getParent() System.out.println()) System.out.println("Location doesn't exist."); return; if(Files.exists(destination)) System.out.println("File already exist on the location"); Files.copy(source, destination); System.out.println("File"+source.getFileName()+"is copied"); catch (IOException ex) System.out.println(ex);)))}}
-
PROMENA NAZIVA FILEA
import java.io.File;
METODA
rename to
public static void main(String [] args){ File oldfile = new File("C:\JavaPractice\oldname.txt"); File newfile = new File("C:\JavaPractice\newname.txt"); if (!oldfile.exists()){System.out.println("File doesn't exist."); return;} if (newfile.exists()) {System.out.println("File with desired name already exists."); return; }if (oldfile.renameTo(newfile)){System.out.println("Rename successful")} else {System.out.println("Rename failed.")}