3 Ekim 2016 Pazartesi

BasicFileAttributes Sınıfı

constructor 
Şöyle yaparız
Path file = ...;
BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
creationTime metodu
Şöyle yaparız
System.out.println("creationTime: " + attr.creationTime());
lastAccessTime metodu
Şöyle yaparız
System.out.println("lastAccessTime: " + attr.lastAccessTime());
lastModifiedTime metodu
Şöyle yaparız
System.out.println("lastModifiedTime: " + attr.lastModifiedTime());


30 Eylül 2016 Cuma

Stopwatch Sınıfı

createStarted metodu
Şöyle yaparız.
Stopwatch stopwatch = Stopwatch.createStarted();
stop metodu
Şöyle yaparız.
stopwatch.stop ();

long totalWorkTimeMillis = stopwatch.elapsedMillis ();


28 Eylül 2016 Çarşamba

Response Sınıfı

readEntity metodu
Şöyle yaparız.
Response response = ...;
String result = response.readEntity(String.class);

Invocation.Builder Arayüzü

post metodu
Şöyle yaparız.
Foo foo = new Foo();
user.setUserName("euler");
user.setPassword("password");
Response response = invocation.builder. .post(Entity.json(foo));


JAX-RS ClientBuilder Sınıfı

Giriş
Şu satırı dahil ederiz.
import javax.ws.rs.client.ClientBuilder;
newClient
Client Arayüzü döner. Şöyle yaparız.
Client client = ClientBuilder.newClient ();


27 Eylül 2016 Salı

NamedNodeMap Sınıfı

Giriş
Şu satırı dahil ederiz.
import org.w3c.dom.NamedNodeMap;
getLength metodu
Şöyle yaparız.
NamedNodeMap attributes = ...;

for (int i = 0; i < attributes.getLength(); i++) {
  Node attribute = attributes.item(i);
  if (attribute.getNodeName() == "id") {
    String x = attribute.getNodeValue();
  }  
}

Element Sınıfı

Giriş
Node sınıfından kalıtır. Node'ları dolaşırken Element olduğu şöyle anlaşılır.
Node nNode = nList.item(index);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
  Element eElement = (Element) nNode;
  ...
}
getAttribute metodu
Şöyle yaparız.
Element element = ...;
String attribute = element.getAttribute("isNull");
Şöyle bir element için 85 döner. Attribute yoksa "" yani boş string döner.
<marks isNull= "85" />
getTextContent metodu
Şöyle yaparız.
Element element = ...;
String text = element.getTextContent();
Şöyle bir element için 95 döner.
<marks>95</marks>