Professional Documents
Culture Documents
Novosti u Javi 7
Project COIN, Novi I/O
http://javasvet.rs
info@javasvet.rs
JavaSvet
Project COIN
<> dijamant itljivija notacija velikih brojeva Switchu stringu Multi-catch Try-with-resources
http://javasvet.rs
info@javasvet.rs
JavaSvet
<>
Pre generika List list = new ArrayList() Sa genericima List<List<String>> list = new ArrayList<List<String>>() Dijamantska verzija List<List<String>> list = new ArrayList<>()
http://javasvet.rs info@javasvet.rs
JavaSvet
<>
http://javasvet.rs
info@javasvet.rs
http://javasvet.rs
info@javasvet.rs
JavaSvet
String u switch-u
final String day = "weekend"; switch (day) { case "workday": System.out.println("buuu!"); break; case "weekend" System.out.println("jeej!"); break; default: break; }
http://javasvet.rs info@javasvet.rs
JavaSvet
Multi-catch
JavaSvet
Multi-catch
http://javasvet.rs
info@javasvet.rs
JavaSvet
Multi-catch
http://javasvet.rs
info@javasvet.rs
JavaSvet
Try-with-resources
JavaSvet
New I/O zato?
Dosta metoda nije bacalo exception (delete, mkdir vraaju bool umesto exceptiona) Trenutno API nije konzistentant na svim platformama Nedostatak osnovnih operacija (copy, move...) Nema notifikacija kada je fajl promenjen
http://javasvet.rs info@javasvet.rs
JavaSvet
Novi I/O API
java.nio.file paket
Path putanja fajla na fajl sistemu Files statike metode za rad za fajlovima/folderima FileSystem pristup fajl sistemu, factory za objekte za pristup fajl sistemu
http://javasvet.rs
info@javasvet.rs
JavaSvet
Novi I/O API
java.nio.file
http://javasvet.rs
info@javasvet.rs
JavaSvet
Novi I/O API
File Attributes
Pristup bazinim atributima (ime, veliina, timestampovi) Pristup atributima specifini za odreene platforme
http://javasvet.rs
info@javasvet.rs
JavaSvet
Novi I/O API
Primeri
Files.copy(InputStream source, Path target, CopyOptions REPLACE_EXISTING); try { Files.delete(path); } catch (NoSuchFileException x) { // No such file } catch (DirectoryNotEmptyException x) { // Folder not empty } catch (IOException x) { // Something else, permissions maybe? }
http://javasvet.rs info@javasvet.rs
JavaSvet
Pitanja?
http://javasvet.rs
info@javasvet.rs
JavaSvet
Hvala na panji
Vuk Nikoli
@vuknikolic vuk.nikolic@javasvet.rs
http://javasvet.rs
info@javasvet.rs