<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1661517518925762010</id><updated>2026-03-30T11:17:08.949-07:00</updated><category term="code snap"/><category term="JavaFX"/><category term="reference"/><category term="fundamental.Java"/><category term="JavaFX 8 example"/><category term="Swing"/><category term="tools"/><category term="how to"/><category term="NetBeans"/><category term="news"/><category term="Java 8"/><category term="JDK"/><category term="Java 8 example"/><category term="info"/><category term="JDK8"/><category term="FXML"/><category term="Java Network Programming"/><category term="JavaFX 8"/><category term="Raspberry Pi"/><category term="JavaEE"/><category term="Graphics2D"/><category term="javafx.animation"/><category term="JavaOne"/><category term="Android"/><category term="Maps"/><category term="Scene Builder"/><category term="installation"/><category term="nio"/><category term="IntelliJ"/><category term="Network programming"/><category term="Internet of Things (IoT)"/><category term="Java EE"/><category term="Linux"/><category term="Windows 10"/><category term="awt"/><category term="nashorn JavaScript Engine"/><category term="Apps"/><category term="Arduino"/><category term="JSON"/><category term="Java 7"/><category term="OpenJDK"/><category term="OpenWeatherMap"/><category term="Oracle"/><category term="RxTx"/><category term="Windows 8"/><category term="java8"/><category term="Google Translate"/><category term="HTML5"/><category term="HttpServer"/><category term="ImageIO"/><category term="Java ME Embedded"/><category term="Java Magazine"/><category term="Java Web Services"/><category term="JavaFX 3D"/><category term="OpenCV"/><category term="OpenJFX"/><category term="Serial Communication"/><category term="Text-to-speech (tts)"/><category term="WhoisClient"/><category term="ZXing"/><category term="css"/><category term="jSSC - java serial port communication library"/><category term="java-google-translate-text-to-speech"/><category term="C/C++"/><category term="DukeScript"/><category term="Eclipse SmartHome"/><category term="Files"/><category term="Game Development"/><category term="Geo"/><category term="Google"/><category term="Google Maps"/><category term="JAX-RS"/><category term="JSF"/><category term="JUnit"/><category term="Java 9"/><category term="Java I/O"/><category term="Java ME"/><category term="Java SE Embedded"/><category term="JavaFX Scene Builder 2.0"/><category term="JavaFX on Mobile"/><category term="Jdeveloper"/><category term="Lambda Expression"/><category term="Networking"/><category term="Oracle ADF Mobile"/><category term="Oracle Certified Exams"/><category term="Scala"/><category term="ServerSocket"/><category term="TCP"/><category term="UDP"/><category term="ask for help"/><category term="iOS"/><category term="java-gnome"/><category term="java-json"/><category term="mobile"/><category term="new"/><category term="tips.FXML"/><title type='text'>Java-Buddy</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Erik</name><uri>http://www.blogger.com/profile/04983894331825656853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>734</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-7510947745226629544</id><published>2016-07-20T09:21:00.001-07:00</published><updated>2016-07-20T09:30:11.870-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Network programming"/><title type='text'>Java example of SSL Server and Client, and how to generate keystore </title><content type='html'>Here are examples of Java SSL Server and Client.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH2OpfvvjB9n-ivRcQfU0vkbcCmsrz6M2eESPO0xUt04Jv2UZ5X6HDlaz6nDhlfk7KaBaiHgCPY73yRfNx7wJXlpTr1p39gPFzvuPBWs9sNwrZDhLMsH2DYxVM_6Y7g372iSkI_eFgbvlB/s1600/SSLServer+and+Client.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH2OpfvvjB9n-ivRcQfU0vkbcCmsrz6M2eESPO0xUt04Jv2UZ5X6HDlaz6nDhlfk7KaBaiHgCPY73yRfNx7wJXlpTr1p39gPFzvuPBWs9sNwrZDhLMsH2DYxVM_6Y7g372iSkI_eFgbvlB/s640/SSLServer+and+Client.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
JavaSSLServer.java
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javasslserver;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLServerSocketFactory;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaSSLServer {
    
    static final int port = 8000;

    public static void main(String[] args) {
        
        
        SSLServerSocketFactory sslServerSocketFactory = 
                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
        
        try {
            ServerSocket sslServerSocket = 
                    sslServerSocketFactory.createServerSocket(port);
            System.out.println(&quot;SSL ServerSocket started&quot;);
            System.out.println(sslServerSocket.toString());
            
            Socket socket = sslServerSocket.accept();
            System.out.println(&quot;ServerSocket accepted&quot;);
            
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            try (BufferedReader bufferedReader = 
                    new BufferedReader(
                            new InputStreamReader(socket.getInputStream()))) {
                String line;
                while((line = bufferedReader.readLine()) != null){
                    System.out.println(line);
                    out.println(line);
                }
            }
            System.out.println(&quot;Closed&quot;);
            
        } catch (IOException ex) {
            Logger.getLogger(JavaSSLServer.class.getName())
                    .log(Level.SEVERE, null, ex);
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
JavaSSLClient.java
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javasslclient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLSocketFactory;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaSSLClient {
    
    static final int port = 8000;

    public static void main(String[] args) {
        
        SSLSocketFactory sslSocketFactory = 
                (SSLSocketFactory)SSLSocketFactory.getDefault();
        try {
            Socket socket = sslSocketFactory.createSocket(&quot;localhost&quot;, port);
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            try (BufferedReader bufferedReader = 
                    new BufferedReader(
                            new InputStreamReader(socket.getInputStream()))) {
                Scanner scanner = new Scanner(System.in);
                while(true){
                    System.out.println(&quot;Enter something:&quot;);
                    String inputLine = scanner.nextLine();
                    if(inputLine.equals(&quot;q&quot;)){
                        break;
                    }
                    
                    out.println(inputLine);
                    System.out.println(bufferedReader.readLine());
                }
            }
            
        } catch (IOException ex) {
            Logger.getLogger(JavaSSLClient.class.getName())
                    .log(Level.SEVERE, null, ex);
        }
         
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Without keystore, both the server and client will fail. This video show how to generate keystore using keytool program. Then run server and client with keystore and password.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/X4WImgwvjDw&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
Type the following command in your command window to create a keystore named examplestore and to generate keys:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;$ keytool -genkey -alias signFiles -keystore examplestore&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted to enter passwords for the key and keystore. The password in this example is &quot;password&quot;.&lt;br /&gt;
&lt;br /&gt;
(reference:&amp;nbsp;&lt;a href=&quot;https://docs.oracle.com/javase/tutorial/security/toolsign/step3.html&quot; target=&quot;_blank&quot;&gt;https://docs.oracle.com/javase/tutorial/security/toolsign/step3.html&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Run SSL server and client by entering the commands:&lt;br /&gt;
&lt;b&gt;$ java -jar -Djavax.net.ssl.keyStore=keystore -Djavax.net.ssl.keyStorePassword=password &quot;...JavaSSLServer.jar&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;$ java -jar -Djavax.net.ssl.trustStore=keystore -Djavax.net.ssl.trustStorePassword=password &quot;...JavaSSLClient.jar&quot;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/7510947745226629544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/07/java-example-of-ssl-server-and-client.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7510947745226629544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7510947745226629544'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/07/java-example-of-ssl-server-and-client.html' title='Java example of SSL Server and Client, and how to generate keystore '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH2OpfvvjB9n-ivRcQfU0vkbcCmsrz6M2eESPO0xUt04Jv2UZ5X6HDlaz6nDhlfk7KaBaiHgCPY73yRfNx7wJXlpTr1p39gPFzvuPBWs9sNwrZDhLMsH2DYxVM_6Y7g372iSkI_eFgbvlB/s72-c/SSLServer+and+Client.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-117434799054438673</id><published>2016-06-16T09:25:00.001-07:00</published><updated>2016-06-16T09:25:24.110-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java 8 example"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>Read csv, run in background thread and update JavaFX TableView dynamically</title><content type='html'>&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/8UVbhzuYFIw&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
It&#39;s modified version of last example &quot;&lt;a href=&quot;http://java-buddy.blogspot.com/2016/06/read-csv-file-display-in-javafx.html&quot;&gt;Read csv file, display in JavaFX TableView&lt;/a&gt;&quot;, with the job run in background thread. I also add dummy delay to simulate long time operation in background thread.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2VRxZCB6SYZI66nquUX3aS36dSajlfn8ptR7FMqZYQtR3OIBdMKbODZ6ltzHi_QWJOPdKlpZS1QGu4azmBSrEl3Ke7PUmMbuiVOpjSGLtGi70LxRwvCFM8UEKbC8-vZIVU00zBKQN8tUL/s1600/JavaFXCSVTableView+in+background+thread.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2VRxZCB6SYZI66nquUX3aS36dSajlfn8ptR7FMqZYQtR3OIBdMKbODZ6ltzHi_QWJOPdKlpZS1QGu4azmBSrEl3Ke7PUmMbuiVOpjSGLtGi70LxRwvCFM8UEKbC8-vZIVU00zBKQN8tUL/s640/JavaFXCSVTableView+in+background+thread.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
JavaFXCSVTableView.java
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxcsvtableview;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXCSVTableView extends Application {

    public class Record {
        //Assume each record have 6 elements, all String

        private SimpleStringProperty f1, f2, f3, f4, f5, f6;

        public String getF1() {
            return f1.get();
        }

        public String getF2() {
            return f2.get();
        }

        public String getF3() {
            return f3.get();
        }

        public String getF4() {
            return f4.get();
        }

        public String getF5() {
            return f5.get();
        }

        public String getF6() {
            return f6.get();
        }

        Record(String f1, String f2, String f3, String f4,
                String f5, String f6) {
            this.f1 = new SimpleStringProperty(f1);
            this.f2 = new SimpleStringProperty(f2);
            this.f3 = new SimpleStringProperty(f3);
            this.f4 = new SimpleStringProperty(f4);
            this.f5 = new SimpleStringProperty(f5);
            this.f6 = new SimpleStringProperty(f6);
        }

    }

    private final TableView&amp;lt;Record&amp;gt; tableView = new TableView&amp;lt;&amp;gt;();

    private final ObservableList&amp;lt;Record&amp;gt; dataList
            = FXCollections.observableArrayList();

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);

        Group root = new Group();

        TableColumn columnF1 = new TableColumn(&quot;f1&quot;);
        columnF1.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f1&quot;));

        TableColumn columnF2 = new TableColumn(&quot;f2&quot;);
        columnF2.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f2&quot;));

        TableColumn columnF3 = new TableColumn(&quot;f3&quot;);
        columnF3.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f3&quot;));

        TableColumn columnF4 = new TableColumn(&quot;f4&quot;);
        columnF4.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f4&quot;));

        TableColumn columnF5 = new TableColumn(&quot;f5&quot;);
        columnF5.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f5&quot;));

        TableColumn columnF6 = new TableColumn(&quot;f6&quot;);
        columnF6.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f6&quot;));

        tableView.setItems(dataList);
        tableView.getColumns().addAll(
                columnF1, columnF2, columnF3, columnF4, columnF5, columnF6);

        VBox vBox = new VBox();
        vBox.setSpacing(10);
        vBox.getChildren().add(tableView);

        root.getChildren().add(vBox);

        primaryStage.setScene(new Scene(root, 700, 250));
        primaryStage.show();

        //readCSV();
        
        //run in background thread
        new Thread() {
            
            @Override
            public void run() {
                readCSV();
            };
            
        }.start();
        
    }

    private void readCSV() {
        
        System.out.println(&quot;Platform.isFxApplicationThread(): &quot;
                        + Platform.isFxApplicationThread());

        String CsvFile = &quot;/home/buddy/test/test.csv&quot;;
        String FieldDelimiter = &quot;,&quot;;

        BufferedReader br;

        try {
            br = new BufferedReader(new FileReader(CsvFile));

            String line;
            while ((line = br.readLine()) != null) {
                String[] fields = line.split(FieldDelimiter, -1);

                Record record = new Record(fields[0], fields[1], fields[2],
                        fields[3], fields[4], fields[5]);
                dataList.add(record);

                //Add delay to simulate long time operation
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ex) {
                    Logger.getLogger(JavaFXCSVTableView.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(JavaFXCSVTableView.class.getName())
                    .log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(JavaFXCSVTableView.class.getName())
                    .log(Level.SEVERE, null, ex);
        }

    }

    public static void main(String[] args) {
        launch(args);
    }

}

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/117434799054438673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/06/read-csv-run-in-background-thread-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/117434799054438673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/117434799054438673'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/06/read-csv-run-in-background-thread-and.html' title='Read csv, run in background thread and update JavaFX TableView dynamically'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/8UVbhzuYFIw/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-3137120078675450208</id><published>2016-06-16T08:52:00.000-07:00</published><updated>2016-06-16T09:26:59.349-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>Read csv file, display in JavaFX TableView</title><content type='html'>Java example read csv file and display the content in&amp;nbsp;JavaFX TableView.&lt;br /&gt;
&lt;br /&gt;
To know how to prepare the csv file, and simple read csv file, refer to &lt;a href=&quot;http://java-buddy.blogspot.com/2016/06/java-to-read-csv-file.html&quot;&gt;last post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYaj5UJSHZdGCU5DdrBq_WfU2AkWPL84GiXvRk2v_-VK6LRHdXElbUAxwj-wljZBXB5LAzjsxZmMkm-DH-hdJRZUEQbvl_Kh0yGOFIUjzgJ37t3HUMFGto2xyptBabgB6ftPM-AUdeEZbA/s1600/JavaFXCSVTableView.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYaj5UJSHZdGCU5DdrBq_WfU2AkWPL84GiXvRk2v_-VK6LRHdXElbUAxwj-wljZBXB5LAzjsxZmMkm-DH-hdJRZUEQbvl_Kh0yGOFIUjzgJ37t3HUMFGto2xyptBabgB6ftPM-AUdeEZbA/s640/JavaFXCSVTableView.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
JavaFXCSVTableView.java
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxcsvtableview;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXCSVTableView extends Application {

    public class Record {
        //Assume each record have 6 elements, all String

        private SimpleStringProperty f1, f2, f3, f4, f5, f6;

        public String getF1() {
            return f1.get();
        }

        public String getF2() {
            return f2.get();
        }

        public String getF3() {
            return f3.get();
        }

        public String getF4() {
            return f4.get();
        }

        public String getF5() {
            return f5.get();
        }

        public String getF6() {
            return f6.get();
        }

        Record(String f1, String f2, String f3, String f4,
                String f5, String f6) {
            this.f1 = new SimpleStringProperty(f1);
            this.f2 = new SimpleStringProperty(f2);
            this.f3 = new SimpleStringProperty(f3);
            this.f4 = new SimpleStringProperty(f4);
            this.f5 = new SimpleStringProperty(f5);
            this.f6 = new SimpleStringProperty(f6);
        }

    }

    private final TableView&amp;lt;Record&amp;gt; tableView = new TableView&amp;lt;&amp;gt;();

    private final ObservableList&amp;lt;Record&amp;gt; dataList
            = FXCollections.observableArrayList();

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);

        Group root = new Group();

        TableColumn columnF1 = new TableColumn(&quot;f1&quot;);
        columnF1.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f1&quot;));

        TableColumn columnF2 = new TableColumn(&quot;f2&quot;);
        columnF2.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f2&quot;));

        TableColumn columnF3 = new TableColumn(&quot;f3&quot;);
        columnF3.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f3&quot;));

        TableColumn columnF4 = new TableColumn(&quot;f4&quot;);
        columnF4.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f4&quot;));

        TableColumn columnF5 = new TableColumn(&quot;f5&quot;);
        columnF5.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f5&quot;));

        TableColumn columnF6 = new TableColumn(&quot;f6&quot;);
        columnF6.setCellValueFactory(
                new PropertyValueFactory&amp;lt;&amp;gt;(&quot;f6&quot;));

        tableView.setItems(dataList);
        tableView.getColumns().addAll(
                columnF1, columnF2, columnF3, columnF4, columnF5, columnF6);

        VBox vBox = new VBox();
        vBox.setSpacing(10);
        vBox.getChildren().add(tableView);

        root.getChildren().add(vBox);

        primaryStage.setScene(new Scene(root, 700, 250));
        primaryStage.show();

        readCSV();
    }

    private void readCSV() {

        String CsvFile = &quot;/home/buddy/test/test.csv&quot;;
        String FieldDelimiter = &quot;,&quot;;

        BufferedReader br;

        try {
            br = new BufferedReader(new FileReader(CsvFile));

            String line;
            while ((line = br.readLine()) != null) {
                String[] fields = line.split(FieldDelimiter, -1);

                Record record = new Record(fields[0], fields[1], fields[2],
                        fields[3], fields[4], fields[5]);
                dataList.add(record);

            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(JavaFXCSVTableView.class.getName())
                    .log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(JavaFXCSVTableView.class.getName())
                    .log(Level.SEVERE, null, ex);
        }

    }

    public static void main(String[] args) {
        launch(args);
    }

}

&lt;/pre&gt;
&lt;br /&gt;
&lt;a href=&quot;http://java-buddy.blogspot.com/2016/06/read-csv-run-in-background-thread-and.html&quot;&gt;Next post&lt;/a&gt; show how to do the job in background.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/3137120078675450208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/06/read-csv-file-display-in-javafx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3137120078675450208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3137120078675450208'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/06/read-csv-file-display-in-javafx.html' title='Read csv file, display in JavaFX TableView'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYaj5UJSHZdGCU5DdrBq_WfU2AkWPL84GiXvRk2v_-VK6LRHdXElbUAxwj-wljZBXB5LAzjsxZmMkm-DH-hdJRZUEQbvl_Kh0yGOFIUjzgJ37t3HUMFGto2xyptBabgB6ftPM-AUdeEZbA/s72-c/JavaFXCSVTableView.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-1502481263225316091</id><published>2016-06-15T10:03:00.002-07:00</published><updated>2016-06-16T08:53:24.909-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fundamental.Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Java 8 example"/><title type='text'>Java to read csv file</title><content type='html'>This example show how to read csv file using Java.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIpIctgsgYWdgNyt4y1eE0PUCmofvNCKQRkVVW6DPwBXX8uaCzty41ApQiAwXpCgDBNkfw-orfDI-flXKvajVM3G5fD311w_GAlXf9ur0Y15nmePxERPcwr4P4_irXCgb1Y_j2CwaSc6Z5/s1600/JavaReadCSV.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;329&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIpIctgsgYWdgNyt4y1eE0PUCmofvNCKQRkVVW6DPwBXX8uaCzty41ApQiAwXpCgDBNkfw-orfDI-flXKvajVM3G5fD311w_GAlXf9ur0Y15nmePxERPcwr4P4_irXCgb1Y_j2CwaSc6Z5/s640/JavaReadCSV.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Prepare:&lt;br /&gt;
- Create a spreadsheet:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCcQh-k7kXhcrJquQSwXZACUgQ6DxOyXj6KrEpCBTUh7AKJ10vZmbrSG1ogSpC5teW2FG10D9ly1Rm9RcIjwuuVSCkztC1RPlvk1oW4_6oXBk_oNDOIV0Dy83uknPlVwdw3dx5Q_v1dISp/s1600/test.ods.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCcQh-k7kXhcrJquQSwXZACUgQ6DxOyXj6KrEpCBTUh7AKJ10vZmbrSG1ogSpC5teW2FG10D9ly1Rm9RcIjwuuVSCkztC1RPlvk1oW4_6oXBk_oNDOIV0Dy83uknPlVwdw3dx5Q_v1dISp/s640/test.ods.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
- Export as csv file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4RY_5SYr8G2A0XzPOVcBkB4SZuMGTapposx4olGvfuvc25KRqzEXQczytUkMiWhC8Uy3vEZGQqGUdAuu3B8ZklZlfjsqw8BGo_s0JEzVsoSDhTItqwybcDImvatMpdwJjJNZCiBu6ec5Q/s1600/test.csv.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4RY_5SYr8G2A0XzPOVcBkB4SZuMGTapposx4olGvfuvc25KRqzEXQczytUkMiWhC8Uy3vEZGQqGUdAuu3B8ZklZlfjsqw8BGo_s0JEzVsoSDhTItqwybcDImvatMpdwJjJNZCiBu6ec5Q/s640/test.csv.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
- The exported csv file in text format:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYXuQQ4DUM86N8S98I4SyzaeqYa1yPe2QOdCQstljJvivGzOGcKnJPEgUM0kZAEx0qD2Ls6YJe4Ef9hxJf-pv8wdDpR7uR6SkkbQZcyPEBxtFzKn4uG0xXRopp_X5lytjJeFrCYeJlepq/s1600/test.csv.text.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;430&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYXuQQ4DUM86N8S98I4SyzaeqYa1yPe2QOdCQstljJvivGzOGcKnJPEgUM0kZAEx0qD2Ls6YJe4Ef9hxJf-pv8wdDpR7uR6SkkbQZcyPEBxtFzKn4uG0xXRopp_X5lytjJeFrCYeJlepq/s640/test.csv.text.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Using java to read the csv file and print the content:&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javareadcsv;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaReadCSV {
    
    static String CsvFile = &quot;/home/buddy/test/test.csv&quot;;
    static String FieldDelimiter = &quot;,&quot;;

    public static void main(String[] args) throws IOException {
        BufferedReader br;
        
        try {
            br = new BufferedReader(new FileReader(CsvFile));
            
            String line;
            while ((line = br.readLine()) != null) {
                String[] fields = line.split(FieldDelimiter, -1);
                System.out.print(fields.length + &quot;-&quot;);
                for(String s : fields){
                    System.out.print(s);
                    System.out.print(&quot;:&quot;);
                }
                System.out.println();
            }
            
        } catch (FileNotFoundException ex) {
            Logger.getLogger(JavaReadCSV.class.getName())
                    .log(Level.SEVERE, null, ex);
        }
        
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
To display the content with JavaFX TableView, read &lt;a href=&quot;http://java-buddy.blogspot.com/2016/06/read-csv-file-display-in-javafx.html&quot;&gt;next post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/1502481263225316091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/06/java-to-read-csv-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1502481263225316091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1502481263225316091'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/06/java-to-read-csv-file.html' title='Java to read csv file'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIpIctgsgYWdgNyt4y1eE0PUCmofvNCKQRkVVW6DPwBXX8uaCzty41ApQiAwXpCgDBNkfw-orfDI-flXKvajVM3G5fD311w_GAlXf9ur0Y15nmePxERPcwr4P4_irXCgb1Y_j2CwaSc6Z5/s72-c/JavaReadCSV.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-8846046466287434116</id><published>2016-06-07T16:56:00.001-07:00</published><updated>2016-06-07T17:10:53.859-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java 8 example"/><title type='text'>Java example using Supplier to get input from Scanner</title><content type='html'>Java example using&amp;nbsp;java.util.function.Supplier to get input from&amp;nbsp;java.util.Scanner.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCqMbVjmbBBCA_R7sr6sjBwYv66LE95_XrRX6-PWfdHXx0ILPUmSPykEKRA_oBMpNZYtmey_-MkMSUCDYMy2Ws3yhhJe7WaaVhfnTuL4fw_UONvG7p5ERotXE0EHrAxrRm19_n8Dscbx6v/s1600/JavaSupplier.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCqMbVjmbBBCA_R7sr6sjBwYv66LE95_XrRX6-PWfdHXx0ILPUmSPykEKRA_oBMpNZYtmey_-MkMSUCDYMy2Ws3yhhJe7WaaVhfnTuL4fw_UONvG7p5ERotXE0EHrAxrRm19_n8Dscbx6v/s640/JavaSupplier.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
JavaSupplier.java
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javasupplier;

import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class JavaSupplier {

    public static void main(String[] args) {
        Supplier&amp;lt;String&amp;gt; msg  = ()-&amp;gt; &quot;http://java-buddy.blogspot.com/&quot;;
        System.out.println(msg.get());
        System.out.println();
        
        Scanner scanner = new Scanner(System.in);
        Supplier&amp;lt;String&amp;gt; scannerNext = () -&amp;gt; scanner.next();
        System.out.println(&quot;Enter something, &#39;q&#39; to quit&quot;);
        
        Stream.generate(scannerNext)
                .map(s -&amp;gt; {
                    System.out.println(s);
                    return s;
                })
                .allMatch(s -&amp;gt; !&quot;q&quot;.equals(s));
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/gami7F05NaI&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/8846046466287434116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/06/java-example-using-supplier-to-get.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/8846046466287434116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/8846046466287434116'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/06/java-example-using-supplier-to-get.html' title='Java example using Supplier to get input from Scanner'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCqMbVjmbBBCA_R7sr6sjBwYv66LE95_XrRX6-PWfdHXx0ILPUmSPykEKRA_oBMpNZYtmey_-MkMSUCDYMy2Ws3yhhJe7WaaVhfnTuL4fw_UONvG7p5ERotXE0EHrAxrRm19_n8Dscbx6v/s72-c/JavaSupplier.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-7122611390070491323</id><published>2016-04-17T04:59:00.000-07:00</published><updated>2016-04-17T04:59:21.742-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><title type='text'>Get my MAC address using NetworkInterface</title><content type='html'>Java example to get MAC address using&amp;nbsp;NetworkInterface:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbFvxyw-9duKRKO4JzUmIhLriyNXfZFLBJTYzKiXPJqvZoRzyYOlOAtIRp2Q3B4GJCHazW-3Xgiqg62Y5R6d5fk20hGBrfjitGtd6rg5aBYHhRIzMJ_FcMwvtE26uJxrcVfX004vT5wIXj/s1600/get+MAC+address.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbFvxyw-9duKRKO4JzUmIhLriyNXfZFLBJTYzKiXPJqvZoRzyYOlOAtIRp2Q3B4GJCHazW-3Xgiqg62Y5R6d5fk20hGBrfjitGtd6rg5aBYHhRIzMJ_FcMwvtE26uJxrcVfX004vT5wIXj/s640/get+MAC+address.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javamyip;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaMyIP {

    public static void main(String[] args) {
        displayMyIP();
    }
    
    static void displayMyIP(){
        Enumeration&amp;lt;NetworkInterface&amp;gt; nets;
        try {
            nets = NetworkInterface.getNetworkInterfaces();
            for (NetworkInterface netint : Collections.list(nets)){
                System.out.printf(netint.getDisplayName() +&quot;\n&quot;);
                Enumeration&amp;lt;InetAddress&amp;gt; inetAddresses = netint.getInetAddresses();
                for (InetAddress inetAddress : Collections.list(inetAddresses)) {
                    System.out.printf(&quot;InetAddress: %s\n&quot;, inetAddress);
                }
                
                byte[] mac = netint.getHardwareAddress();
                if(mac != null){
                    StringBuilder macAddr = new StringBuilder();
                    for (int i = 0; i &amp;lt; mac.length; i++) {
                        macAddr.append(String.format(&quot;%02X%s&quot;, mac[i], (i &amp;lt; mac.length - 1) ? &quot;:&quot; : &quot;&quot;)); 
                    }
                    System.out.printf(&quot;Hardware address (MAC): [%s]\n&quot;, macAddr.toString());
                }
                
                System.out.printf(&quot;\n&quot;);
            }
        } catch (SocketException ex) {
            Logger.getLogger(JavaMyIP.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/7122611390070491323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/04/get-my-mac-address-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7122611390070491323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7122611390070491323'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/04/get-my-mac-address-using.html' title='Get my MAC address using NetworkInterface'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbFvxyw-9duKRKO4JzUmIhLriyNXfZFLBJTYzKiXPJqvZoRzyYOlOAtIRp2Q3B4GJCHazW-3Xgiqg62Y5R6d5fk20hGBrfjitGtd6rg5aBYHhRIzMJ_FcMwvtE26uJxrcVfX004vT5wIXj/s72-c/get+MAC+address.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-1834267496707008497</id><published>2016-04-15T18:36:00.001-07:00</published><updated>2016-04-15T18:38:26.664-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><title type='text'>List my IP (inetAddress)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqs7AqzQLiADLwiWjZ2ena-c2tlz4HsdWPKOzGgYDLcPDDyjKJGsZnpQUPR5SbynDilNlGWhh6jUTSakwk_Fd5T1kFmg4WIUIrSY5eY4lzKyEfhgXIWk2Nfq3xhYjmfYHSY-0IYu0ao0HE/s1600/JavaMyIP.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqs7AqzQLiADLwiWjZ2ena-c2tlz4HsdWPKOzGgYDLcPDDyjKJGsZnpQUPR5SbynDilNlGWhh6jUTSakwk_Fd5T1kFmg4WIUIrSY5eY4lzKyEfhgXIWk2Nfq3xhYjmfYHSY-0IYu0ao0HE/s640/JavaMyIP.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Java example to list Network Interface Addresses and IP:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javamyip;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaMyIP {

    public static void main(String[] args) {
        displayMyIP();
    }
    
    static void displayMyIP(){
        Enumeration&amp;lt;NetworkInterface&amp;gt; nets;
        try {
            nets = NetworkInterface.getNetworkInterfaces();
            for (NetworkInterface netint : Collections.list(nets)){
                System.out.printf(netint.getDisplayName() +&quot;\n&quot;);
                Enumeration&amp;lt;InetAddress&amp;gt; inetAddresses = netint.getInetAddresses();
                for (InetAddress inetAddress : Collections.list(inetAddresses)) {
                    System.out.printf(&quot;InetAddress: %s\n&quot;, inetAddress);
                }
                System.out.printf(&quot;\n&quot;);
            }
        } catch (SocketException ex) {
            Logger.getLogger(JavaMyIP.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Can use functional operations in Java 8 (auto suggested by Netbeans):
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javamyip;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaMyIP {

    public static void main(String[] args) {
        displayMyIP();
    }
    
    static void displayMyIP(){
        Enumeration&amp;lt;NetworkInterface&amp;gt; nets;
        try {
            nets = NetworkInterface.getNetworkInterfaces();
            Collections.list(nets).stream().map((netint) -&amp;gt; {
                System.out.printf(netint.getDisplayName() +&quot;\n&quot;);
                return netint;
            }).map((netint) -&amp;gt; netint.getInetAddresses()).map((inetAddresses) -&amp;gt; {
                Collections.list(inetAddresses).stream().forEach((inetAddress) -&amp;gt; {
                    System.out.printf(&quot;InetAddress: %s\n&quot;, inetAddress);
                });
                return inetAddresses;
            }).forEach((_item) -&amp;gt; {
                System.out.printf(&quot;\n&quot;);
            });
        } catch (SocketException ex) {
            Logger.getLogger(JavaMyIP.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/1834267496707008497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/04/list-my-ip-inetaddress.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1834267496707008497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1834267496707008497'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/04/list-my-ip-inetaddress.html' title='List my IP (inetAddress)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqs7AqzQLiADLwiWjZ2ena-c2tlz4HsdWPKOzGgYDLcPDDyjKJGsZnpQUPR5SbynDilNlGWhh6jUTSakwk_Fd5T1kFmg4WIUIrSY5eY4lzKyEfhgXIWk2Nfq3xhYjmfYHSY-0IYu0ao0HE/s72-c/JavaMyIP.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-1128657687957998810</id><published>2016-04-13T20:08:00.001-07:00</published><updated>2016-04-13T20:10:17.475-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="ServerSocket"/><title type='text'>Create ServerSocket with automatically allocated port</title><content type='html'>Create ServerSocket by calling constructor&amp;nbsp;&lt;a href=&quot;https://docs.oracle.com/javase/8/docs/api/java/net/ServerSocket.html#ServerSocket-int-&quot; target=&quot;_blank&quot;&gt;ServerSocket(int port)&lt;/a&gt; with port = 0,&amp;nbsp;&amp;nbsp;the port number is automatically allocated, typically from an ephemeral port range. This port number can then be retrieved by calling getLocalPort.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javaechoserver;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaEchoServer {

    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        try {
            //Get a available port by passing 0 
            serverSocket = new ServerSocket(0);
            int port = serverSocket.getLocalPort();
            System.out.println(&quot;Port : &quot; + port);
            
        } catch (IOException ex) {
            Logger.getLogger(JavaEchoServer.class.getName())
                    .log(Level.SEVERE, null, ex);
        } finally {
            if (serverSocket != null){
                try {
                    serverSocket.close();
                } catch (IOException ex) {
                    Logger.getLogger(JavaEchoServer.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
            }
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX41V7YMwu-eFxWnr5k16FkmhPKGbS0Q-GLosBZdE9Ii6dFHFxBDj8gJe8oxCFRS6GPmoNLFJ6-6iMk13ZUmZopaAbiI3qR0h6_zBMNahKD9i6_037nRF-vR94TQ6C73MvbDfReBAbkuf6/s1600/port.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX41V7YMwu-eFxWnr5k16FkmhPKGbS0Q-GLosBZdE9Ii6dFHFxBDj8gJe8oxCFRS6GPmoNLFJ6-6iMk13ZUmZopaAbiI3qR0h6_zBMNahKD9i6_037nRF-vR94TQ6C73MvbDfReBAbkuf6/s640/port.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/1128657687957998810/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/04/create-serversocket-with-automatically.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1128657687957998810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1128657687957998810'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/04/create-serversocket-with-automatically.html' title='Create ServerSocket with automatically allocated port'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX41V7YMwu-eFxWnr5k16FkmhPKGbS0Q-GLosBZdE9Ii6dFHFxBDj8gJe8oxCFRS6GPmoNLFJ6-6iMk13ZUmZopaAbiI3qR0h6_zBMNahKD9i6_037nRF-vR94TQ6C73MvbDfReBAbkuf6/s72-c/port.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-5063455728311726150</id><published>2016-03-25T04:57:00.002-07:00</published><updated>2016-03-25T04:57:48.607-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java 8"/><category scheme="http://www.blogger.com/atom/ns#" term="reference"/><title type='text'>Mastering Concurrency Programming with Java 8</title><content type='html'>Master the principles and techniques of multithreaded programming with the Java 8 Concurrency API&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B012O8S89K/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B012O8S89K&amp;amp;linkCode=as2&amp;amp;tag=pointe&amp;amp;linkId=HVP5XVWCFZPYA4WW&quot;&gt;Mastering Concurrency Programming with Java 8&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=pointe&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B012O8S89K&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;About This Book&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Implement concurrent applications using the Java 8 Concurrency API and its new components&lt;/li&gt;
&lt;li&gt;Improve the performance of your applications or process more data at the same time, taking advantage of all of your resources.&lt;/li&gt;
&lt;li&gt;Construct real-world examples related to machine learning, data mining, image processing, and client/server environments&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Who This Book Is For&lt;/b&gt;&lt;br /&gt;
If you are a competent Java developer with a good understanding of concurrency but have no knowledge of how to effectively implement concurrent programs or use streams to make processes more efficient, then this book is for you.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What You Will Learn&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Design concurrent applications by converting a sequential algorithm into a concurrent one&lt;/li&gt;
&lt;li&gt;Discover how to avoid all the possible problems you can get in concurrent algorithms&lt;/li&gt;
&lt;li&gt;Use the Executor framework to manage concurrent tasks without creating threads&lt;/li&gt;
&lt;li&gt;Extend and modify Executors to adapt their behavior to your needs&lt;/li&gt;
&lt;li&gt;Solve problems using the divide and conquer technique and the Fork/Join framework&lt;/li&gt;
&lt;li&gt;Process massive data sets with parallel streams and Map/Reduce implementation&lt;/li&gt;
&lt;li&gt;Control data-race conditions using concurrent data structures and synchronization mechanisms&lt;/li&gt;
&lt;li&gt;Test and monitor concurrent applications&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;In Detail&lt;/b&gt;&lt;br /&gt;
Concurrency programming allows several large tasks to be divided into smaller sub-tasks, which are further processed as individual tasks that run in parallel. All the sub-tasks are combined together once the required results are achieved; they are then merged to get the final output. The whole process is very complex. This process goes from the design of concurrent algorithms to the testing phase where concurrent applications need extra attention. Java includes a comprehensive API with a lot of ready-to-use components to implement powerful concurrency applications in an easy way, but with a high flexibility to adapt these components to your needs.&lt;br /&gt;
&lt;br /&gt;
The book starts with a full description of design principles of concurrent applications and how to parallelize a sequential algorithm. We&#39;ll show you how to use all the components of the Java Concurrency API from basics to the most advanced techniques to implement them in powerful concurrency applications in Java.&lt;br /&gt;
&lt;br /&gt;
You will be using real-world examples of complex algorithms related to machine learning, data mining, natural language processing, image processing in client / server environments. Next, you will learn how to use the most important components of the Java 8 Concurrency API: the Executor framework to execute multiple tasks in your applications, the phaser class to implement concurrent tasks divided into phases, and the Fork/Join framework to implement concurrent tasks that can be split into smaller problems (using the divide and conquer technique). Toward the end, we will cover the new inclusions in Java 8 API, the Map and Reduce model, and the Map and Collect model. The book will also teach you about the data structures and synchronization utilities to avoid data-race conditions and other critical problems. Finally, the book ends with a detailed description of the tools and techniques that you can use to test a Java concurrent application.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Style and approach&lt;/b&gt;&lt;br /&gt;
A complete guide implementing real-world examples with algorithms related to machine learning, data mining, and natural language processing in client/server environments. All the examples are explained in a step-by-step approach.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;amp;OneJS=1&amp;amp;Operation=GetAdHtml&amp;amp;MarketPlace=US&amp;amp;source=ac&amp;amp;ref=tf_til&amp;amp;ad_type=product_link&amp;amp;tracking_id=pointe&amp;amp;marketplace=amazon&amp;amp;region=US&amp;amp;placement=B012O8S89K&amp;amp;asins=B012O8S89K&amp;amp;linkId=BF6X3XTFM752JHNL&amp;amp;show_border=true&amp;amp;link_opens_in_new_window=true&quot; style=&quot;height: 240px; width: 120px;&quot;&gt;
&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/5063455728311726150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/03/mastering-concurrency-programming-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5063455728311726150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5063455728311726150'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/03/mastering-concurrency-programming-with.html' title='Mastering Concurrency Programming with Java 8'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-1241198830774411535</id><published>2016-03-14T17:08:00.001-07:00</published><updated>2016-03-14T17:08:05.368-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>JavaFX example: open new Window and exit all when primary window close</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkX_H5fyn2OXV0-zT5fuDNefK8eGn3Xdy4zF0n_0u5uaCqqN3VhUxKEh2FDHFpDUXZtq_DW2813-RROxf1JA_8OlK5eRhazQTJVOJlr98N7WF71jnZ3BUpOEwY2xL1oKDZSBYg-J7ZGAMk/s1600/JavaFXWindow.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkX_H5fyn2OXV0-zT5fuDNefK8eGn3Xdy4zF0n_0u5uaCqqN3VhUxKEh2FDHFpDUXZtq_DW2813-RROxf1JA_8OlK5eRhazQTJVOJlr98N7WF71jnZ3BUpOEwY2xL1oKDZSBYg-J7ZGAMk/s640/JavaFXWindow.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
JavaFX example to open new Window, and exit all when primary window close.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxwindow;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXWindow extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText(&quot;Open a New Window&quot;);
        btn.setOnAction((ActionEvent event) -&amp;gt; {
            Label secondLabel = new Label(&quot;Hello&quot;);
            
            StackPane secondaryLayout = new StackPane();
            secondaryLayout.getChildren().add(secondLabel);
            
            Scene secondScene = new Scene(secondaryLayout, 200, 100);
            
            Stage secondStage = new Stage();
            secondStage.setTitle(&quot;New Stage&quot;);
            secondStage.setScene(secondScene);
            
            secondStage.show();

        });
         
        StackPane root = new StackPane();
        root.getChildren().add(btn);
         
        Scene scene = new Scene(root, 300, 250);
         
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);
        primaryStage.setScene(scene);
        primaryStage.show();
        
        primaryStage.setOnCloseRequest(e -&amp;gt; Platform.exit());

    }

    public static void main(String[] args) {
        launch(args);
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/K310akaJ40k&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/1241198830774411535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/03/javafx-example-open-new-window-and-exit.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1241198830774411535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1241198830774411535'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/03/javafx-example-open-new-window-and-exit.html' title='JavaFX example: open new Window and exit all when primary window close'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkX_H5fyn2OXV0-zT5fuDNefK8eGn3Xdy4zF0n_0u5uaCqqN3VhUxKEh2FDHFpDUXZtq_DW2813-RROxf1JA_8OlK5eRhazQTJVOJlr98N7WF71jnZ3BUpOEwY2xL1oKDZSBYg-J7ZGAMk/s72-c/JavaFXWindow.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-9206517949205918870</id><published>2016-03-06T17:16:00.002-08:00</published><updated>2016-03-06T17:22:39.843-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><title type='text'>Read from Internet using URLConnection and BufferedReader</title><content type='html'>Java example to read from Internet using URLConnection and BufferedReader. &lt;i&gt;Thanks for&amp;nbsp;Tomtom&#39;s comment in my last post &quot;&lt;a href=&quot;http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection.html&quot;&gt;Read from Internet using URLConnection and ReadableByteChannel&lt;/a&gt;&quot;.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlykkUnzA4gQm0uc2nXaFO9L7giosZdmzSOGmTHJhK4tFkTaIoHnCrjqmab7RVB1R1wxu-DoamYjOtKrNrZGHWUNB78tpkFdWz_8Eepf7XAiwwL72Jif1HSLExV8Kh6ZKkdPCJ1tf4jxsy/s1600/URLConnection+and+BufferedReader.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlykkUnzA4gQm0uc2nXaFO9L7giosZdmzSOGmTHJhK4tFkTaIoHnCrjqmab7RVB1R1wxu-DoamYjOtKrNrZGHWUNB78tpkFdWz_8Eepf7XAiwwL72Jif1HSLExV8Kh6ZKkdPCJ1tf4jxsy/s640/URLConnection+and+BufferedReader.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javaurlconnection;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaURLConnection {

    public static void main(String[] args) {
        try {
            URL url = new URL(&quot;http://java-buddy.blogspot.com&quot;);
            URLConnection urlConnection = url.openConnection();
            
            /*
            InputStream inputStream = urlConnection.getInputStream();
            try (ReadableByteChannel readableByteChannel = Channels.newChannel(inputStream)) {
                ByteBuffer buffer = ByteBuffer.allocate(1024);
 
                while (readableByteChannel.read(buffer) &amp;gt; 0)
                {
                    String bufferString = new String(buffer.array());
                    System.out.println(bufferString);
                    buffer.clear();
                }
            }
            */
            
            //using BufferedReader
            InputStream inputStream = urlConnection.getInputStream();
            InputStreamReader inputStreamReader = 
                    new InputStreamReader(inputStream);
            BufferedReader buffReader = new BufferedReader(inputStreamReader);
            String line;
            while ((line = buffReader.readLine()) != null) {
                System.out.println(line);
            }
            
        } catch (MalformedURLException ex) {
            Logger.getLogger(JavaURLConnection.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(JavaURLConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/9206517949205918870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection_6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/9206517949205918870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/9206517949205918870'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection_6.html' title='Read from Internet using URLConnection and BufferedReader'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlykkUnzA4gQm0uc2nXaFO9L7giosZdmzSOGmTHJhK4tFkTaIoHnCrjqmab7RVB1R1wxu-DoamYjOtKrNrZGHWUNB78tpkFdWz_8Eepf7XAiwwL72Jif1HSLExV8Kh6ZKkdPCJ1tf4jxsy/s72-c/URLConnection+and+BufferedReader.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-3802764269468530578</id><published>2016-03-03T12:23:00.001-08:00</published><updated>2016-03-06T17:17:52.556-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java 8 example"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><title type='text'>Read from Internet using URLConnection and ReadableByteChannel</title><content type='html'>Java example to read from Internet,&amp;nbsp;&quot;http://java-buddy.blogspot.com&quot;, using&amp;nbsp;URLConnection and ReadableByteChannel.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisb1e3ZLQYujiM6IiW8UiUnYwUyzteGLT6JNZmIul5KVy-jq0ZXSGUpm9d6-k_lH2KzSlBbxzDcQPKpsS4_giqbyOgG5hXa9kg9zlp8ro_ffxfOri49ECWaoK4HzI6vAP6l-Mk5tZ6Gr7L/s1600/URLConnection+and+ReadableByteChannel.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisb1e3ZLQYujiM6IiW8UiUnYwUyzteGLT6JNZmIul5KVy-jq0ZXSGUpm9d6-k_lH2KzSlBbxzDcQPKpsS4_giqbyOgG5hXa9kg9zlp8ro_ffxfOri49ECWaoK4HzI6vAP6l-Mk5tZ6Gr7L/s640/URLConnection+and+ReadableByteChannel.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Example:
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javaurlconnection;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaURLConnection {

    public static void main(String[] args) {
        try {
            URL url = new URL(&quot;http://java-buddy.blogspot.com&quot;);
            URLConnection urlConnection = url.openConnection();
            InputStream inputStream = urlConnection.getInputStream();
            try (ReadableByteChannel readableByteChannel = Channels.newChannel(inputStream)) {
                ByteBuffer buffer = ByteBuffer.allocate(1024);

                while (readableByteChannel.read(buffer) &amp;gt; 0)
                {
                    String bufferString = new String(buffer.array());
                    System.out.println(bufferString);
                    buffer.clear();
                }
            }
        } catch (MalformedURLException ex) {
            Logger.getLogger(JavaURLConnection.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(JavaURLConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Related:&lt;br /&gt;
- &lt;a href=&quot;http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection_6.html&quot;&gt;Read from Internet using URLConnection and BufferedReader&lt;/a&gt;&amp;nbsp;(Thanks Tomtom comment)&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/3802764269468530578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3802764269468530578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3802764269468530578'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/03/read-from-internet-using-urlconnection.html' title='Read from Internet using URLConnection and ReadableByteChannel'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisb1e3ZLQYujiM6IiW8UiUnYwUyzteGLT6JNZmIul5KVy-jq0ZXSGUpm9d6-k_lH2KzSlBbxzDcQPKpsS4_giqbyOgG5hXa9kg9zlp8ro_ffxfOri49ECWaoK4HzI6vAP6l-Mk5tZ6Gr7L/s72-c/URLConnection+and+ReadableByteChannel.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-5310920433395719706</id><published>2016-03-01T15:37:00.000-08:00</published><updated>2016-03-01T15:37:06.403-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fundamental.Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><title type='text'>Get IP address of Website using InetAddress</title><content type='html'>Java example to get IP address of Website using InetAddress:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javainetaddress;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaInetAddress {

    public static void main(String[] args) {
        try {
            InetAddress inetAddress = InetAddress.getByName(&quot;www.google.com&quot;);
            System.out.println(inetAddress);
            System.out.println(inetAddress.getHostName());
            System.out.println(inetAddress.getHostAddress());
        } catch (UnknownHostException ex) {
            Logger.getLogger(JavaInetAddress.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgry1HNB87zMQ5GnpihCzWTeuoz6pPj96X9eMaYwjBP_LrJmosfqvzodiDhVSKdAQTsqb4eQekbJ95x9tXtClaY_kYIyq7vSNbpoAqJEZMsckS9jd2fEPNkoNrRLj6bnbPmPeYdL0OYLxj_/s1600/JavaInetAddress.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgry1HNB87zMQ5GnpihCzWTeuoz6pPj96X9eMaYwjBP_LrJmosfqvzodiDhVSKdAQTsqb4eQekbJ95x9tXtClaY_kYIyq7vSNbpoAqJEZMsckS9jd2fEPNkoNrRLj6bnbPmPeYdL0OYLxj_/s640/JavaInetAddress.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/5310920433395719706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/03/get-ip-address-of-website-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5310920433395719706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5310920433395719706'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/03/get-ip-address-of-website-using.html' title='Get IP address of Website using InetAddress'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgry1HNB87zMQ5GnpihCzWTeuoz6pPj96X9eMaYwjBP_LrJmosfqvzodiDhVSKdAQTsqb4eQekbJ95x9tXtClaY_kYIyq7vSNbpoAqJEZMsckS9jd2fEPNkoNrRLj6bnbPmPeYdL0OYLxj_/s72-c/JavaInetAddress.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-2000172408278981821</id><published>2016-01-09T08:45:00.000-08:00</published><updated>2016-01-09T08:48:49.062-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>JavaFX example to capture screen/GUI nodes</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHJhMj6PPsB_CATZ-7wo1OM2nGmlF5krj1jlDeNvAW0He1ufvqgdq9sIANa0in0402pljaFLPOxxqJYtSnCgCi5KFFi7OpvxacUqOhwHaU0idG2p22bZAKnpbzvUaUHL6pvY-eNXQdlTOL/s1600/JavaFXCaptureScreen.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHJhMj6PPsB_CATZ-7wo1OM2nGmlF5krj1jlDeNvAW0He1ufvqgdq9sIANa0in0402pljaFLPOxxqJYtSnCgCi5KFFi7OpvxacUqOhwHaU0idG2p22bZAKnpbzvUaUHL6pvY-eNXQdlTOL/s640/JavaFXCaptureScreen.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
JavaFX example to capture screen/GUI nodes:
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxcapturescreen;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.control.Button;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javax.imageio.ImageIO;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXCaptureScreen extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        StackPane root = new StackPane();
        Scene scene = new Scene(root, 300, 250);
        
        Button btnCaptureScene = new Button();
        btnCaptureScene.setText(&quot;Capture scene&quot;);
        btnCaptureScene.setOnAction((ActionEvent event) -&amp;gt; {
            
            WritableImage writableImage = scene.snapshot(null);
            File file = new File(&quot;capturedScene.png&quot;);
            try {
                ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), &quot;png&quot;, file);
                System.out.println(&quot;Captured: &quot; + file.getAbsolutePath());
            } catch (IOException ex) {
                Logger.getLogger(JavaFXCaptureScreen.class.getName()).log(Level.SEVERE, null, ex);
            }
        });
        
        Button btnCaptureRoot = new Button();
        btnCaptureRoot.setText(&quot;Capture root&quot;);
        btnCaptureRoot.setOnAction((ActionEvent event) -&amp;gt; {
            WritableImage writableImage = root.snapshot(new SnapshotParameters(), null);

            File file = new File(&quot;capturedRoot.png&quot;);
            try {
                ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), &quot;png&quot;, file);
                System.out.println(&quot;Captured: &quot; + file.getAbsolutePath());
            } catch (IOException ex) {
                Logger.getLogger(JavaFXCaptureScreen.class.getName()).log(Level.SEVERE, null, ex);
            }
        });
        
        VBox vBox = new VBox();
        vBox.getChildren().addAll(btnCaptureScene, btnCaptureRoot);
        root.getChildren().add(vBox);
        
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5wl742tOAlBwKRufbzYcHHCiZn4XYc4ZXiL_uLOwLeRRvZfeB0joMDoNTzPTPYySDxMo9fm54D-6ac-dkWSFXmjgqmPHgyRB5NP4611dSC2hgtLjyROvF6AGIhBXPR5JWK8EHumDQu3P/s1600/capturedScene.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5wl742tOAlBwKRufbzYcHHCiZn4XYc4ZXiL_uLOwLeRRvZfeB0joMDoNTzPTPYySDxMo9fm54D-6ac-dkWSFXmjgqmPHgyRB5NP4611dSC2hgtLjyROvF6AGIhBXPR5JWK8EHumDQu3P/s1600/capturedScene.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;capturedScene.png&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ozFbHONH1IXP8IlQaD_dh_q4SlJTS6dkgDiIA1tYAK7wMjTP4WfsR9DoV2clnn2oD_lrNEyC3eIIobgPXJ9Awxuf-8udS0b9OFcMZtcb5y5KPrTwc25mEXhUziND8_gERULn4yjrYlcv/s1600/capturedRoot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ozFbHONH1IXP8IlQaD_dh_q4SlJTS6dkgDiIA1tYAK7wMjTP4WfsR9DoV2clnn2oD_lrNEyC3eIIobgPXJ9Awxuf-8udS0b9OFcMZtcb5y5KPrTwc25mEXhUziND8_gERULn4yjrYlcv/s1600/capturedRoot.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;capturedRoot.png&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/2000172408278981821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/01/javafx-example-to-capture-screengui.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/2000172408278981821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/2000172408278981821'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/01/javafx-example-to-capture-screengui.html' title='JavaFX example to capture screen/GUI nodes'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHJhMj6PPsB_CATZ-7wo1OM2nGmlF5krj1jlDeNvAW0He1ufvqgdq9sIANa0in0402pljaFLPOxxqJYtSnCgCi5KFFi7OpvxacUqOhwHaU0idG2p22bZAKnpbzvUaUHL6pvY-eNXQdlTOL/s72-c/JavaFXCaptureScreen.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-200275425859500159</id><published>2016-01-07T08:29:00.002-08:00</published><updated>2016-01-07T08:33:05.421-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="awt"/><title type='text'>Capture screen using java.awt.Robot</title><content type='html'>Java example to capture screen using java.awt.Robot:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javarobotcapturescreen;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaRobotCaptureScreen {

    public static void main(String[] args) {
        try {
            Robot robot = new Robot();
            
            Toolkit myToolkit = Toolkit.getDefaultToolkit();
            Dimension screenSize = myToolkit.getScreenSize();
            
            Rectangle screen = new Rectangle(screenSize);
            
            BufferedImage screenFullImage = robot.createScreenCapture(screen);
            ImageIO.write(screenFullImage, &quot;jpg&quot;, new File(&quot;screen.jpg&quot;));
            
        } catch (AWTException | IOException ex) {
            Logger.getLogger(JavaRobotCaptureScreen.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vcXBQ7Vn4m-7yX_MlGuo1ZztBOc4XRTDsh4lm9H0aLGwg-MHD3aZtCqqlzdkM6XhRxSwcPfR6GrjbyoeLbaMGXTOi4LLvy4Uzovq0yHq4sMdr-KVXsI0zczwq7Iij5IBlQ6F8HLFrc08/s1600/JavaRobotCaptureScreen.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vcXBQ7Vn4m-7yX_MlGuo1ZztBOc4XRTDsh4lm9H0aLGwg-MHD3aZtCqqlzdkM6XhRxSwcPfR6GrjbyoeLbaMGXTOi4LLvy4Uzovq0yHq4sMdr-KVXsI0zczwq7Iij5IBlQ6F8HLFrc08/s640/JavaRobotCaptureScreen.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
captured screen:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdEZFF7TmbqqooUCVAzPAQEqTGp07oPmOZnrpAPpWBvnqYPe86Cpo7SKZMR389KjhX2s19KlBS_St0qRbmljgqGjeqYjqE7piLbebKbW4YBW8gLi2j6kOioPmBmX2Dfp6fMABMPzfxXCdO/s1600/screen.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdEZFF7TmbqqooUCVAzPAQEqTGp07oPmOZnrpAPpWBvnqYPe86Cpo7SKZMR389KjhX2s19KlBS_St0qRbmljgqGjeqYjqE7piLbebKbW4YBW8gLi2j6kOioPmBmX2Dfp6fMABMPzfxXCdO/s640/screen.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/200275425859500159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/01/capture-screen-using-javaawtrobot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/200275425859500159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/200275425859500159'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/01/capture-screen-using-javaawtrobot.html' title='Capture screen using java.awt.Robot'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vcXBQ7Vn4m-7yX_MlGuo1ZztBOc4XRTDsh4lm9H0aLGwg-MHD3aZtCqqlzdkM6XhRxSwcPfR6GrjbyoeLbaMGXTOi4LLvy4Uzovq0yHq4sMdr-KVXsI0zczwq7Iij5IBlQ6F8HLFrc08/s72-c/JavaRobotCaptureScreen.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-8426514250552970587</id><published>2016-01-07T02:25:00.001-08:00</published><updated>2016-01-07T02:25:29.024-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="awt"/><title type='text'>Get screen size and resolution, with java.awt.Toolkit</title><content type='html'>Java example to get screen size and resolution, with java.awt.Toolkit:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javagetscreensize;

import java.awt.Dimension;
import java.awt.Toolkit;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaGetScreenSize {

    public static void main(String[] args) {
        Toolkit myToolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = myToolkit.getScreenSize();
        int screenResolution = myToolkit.getScreenResolution();
        System.out.println(&quot;Screen size = &quot; + screenSize.width + &quot; x &quot; + screenSize.height);
        System.out.println(&quot;Screen Resolution: &quot; + screenResolution + &quot; dots-per-inch&quot;);
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8pNNxkMw1-7TForunaW-8uj8xAavJDNMBnLcpQKW1KT4wv176u9pdMHleBiQ4tMUFp3JrmSq4NOVmjj28FdqZdzYbvh0gDgUUn9rP2O1KBsTyUhAWd9GTi0Djr5R_qLOpabDMq5zYtI0b/s1600/java+get+screen+size.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8pNNxkMw1-7TForunaW-8uj8xAavJDNMBnLcpQKW1KT4wv176u9pdMHleBiQ4tMUFp3JrmSq4NOVmjj28FdqZdzYbvh0gDgUUn9rP2O1KBsTyUhAWd9GTi0Djr5R_qLOpabDMq5zYtI0b/s640/java+get+screen+size.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/8426514250552970587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/01/get-screen-size-and-resolution-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/8426514250552970587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/8426514250552970587'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/01/get-screen-size-and-resolution-with.html' title='Get screen size and resolution, with java.awt.Toolkit'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8pNNxkMw1-7TForunaW-8uj8xAavJDNMBnLcpQKW1KT4wv176u9pdMHleBiQ4tMUFp3JrmSq4NOVmjj28FdqZdzYbvh0gDgUUn9rP2O1KBsTyUhAWd9GTi0Djr5R_qLOpabDMq5zYtI0b/s72-c/java+get+screen+size.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-4415883224757159718</id><published>2016-01-07T01:07:00.000-08:00</published><updated>2016-01-07T01:07:04.485-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DukeScript"/><category scheme="http://www.blogger.com/atom/ns#" term="reference"/><title type='text'>Java Everywhere: Write Once run Anywhere with DukeScript</title><content type='html'>&lt;b&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B019Y6QFKY/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B019Y6QFKY&amp;amp;linkCode=as2&amp;amp;tag=pointe&amp;amp;linkId=3CWYYDHWVSRYLDUT&quot; rel=&quot;nofollow&quot;&gt;Java Everywhere: Write Once run Anywhere with DukeScript&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=pointe&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B019Y6QFKY&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Do you want to write Java apps that run on mobile phones, tablets as well as your desktop computer? In this book you&#39;ll learn how to design and develop apps and upload them to Google Play and Apples App Store. The technology we&#39;ll use for that is DukeScript, a new framework for single-source cross-platform development in Java.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;amp;OneJS=1&amp;amp;Operation=GetAdHtml&amp;amp;MarketPlace=US&amp;amp;source=ac&amp;amp;ref=tf_til&amp;amp;ad_type=product_link&amp;amp;tracking_id=pointe&amp;amp;marketplace=amazon&amp;amp;region=US&amp;amp;placement=B019Y6QFKY&amp;amp;asins=B019Y6QFKY&amp;amp;linkId=NQVPKKO3ZKS76RMT&amp;amp;show_border=true&amp;amp;link_opens_in_new_window=true&quot; style=&quot;height: 240px; width: 120px;&quot;&gt;
&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/4415883224757159718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2016/01/java-everywhere-write-once-run-anywhere.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/4415883224757159718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/4415883224757159718'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2016/01/java-everywhere-write-once-run-anywhere.html' title='Java Everywhere: Write Once run Anywhere with DukeScript'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-414160971696277913</id><published>2015-12-28T07:19:00.000-08:00</published><updated>2015-12-28T07:20:34.293-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Files"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>Files.lines() read text file returned by JavaFX FileChooser</title><content type='html'>Example show how to read all lines from a file returned by&amp;nbsp;JavaFX FileChooser, using&amp;nbsp;&lt;a href=&quot;https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#lines-java.nio.file.Path-&quot; target=&quot;_blank&quot;&gt;Files.lines()&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/Zpv4mtzeknU&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxreadtextfile;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFXReadTextFile extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btnLoad = new Button(&quot;Load&quot;);
        btnLoad.setOnAction(btnLoadEventListener);

        VBox rootBox = new VBox();
        rootBox.getChildren().add(btnLoad);
         
        Scene scene = new Scene(rootBox, 300, 300);
         
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
    
    EventHandler&amp;lt;ActionEvent&amp;gt; btnLoadEventListener
    = (ActionEvent event) -&amp;gt; {
        FileChooser fileChooser = new FileChooser();
        fileChooser.getExtensionFilters()
            .addAll(
                new FileChooser.ExtensionFilter(&quot;TXT files (*.TXT)&quot;, &quot;*.TXT&quot;),
                new FileChooser.ExtensionFilter(&quot;txt files (*.txt)&quot;, &quot;*.txt&quot;));
        
        File file = fileChooser.showOpenDialog(null);
        if (file != null) {
            try {
                Files.lines(file.toPath()).forEach(System.out::println);
            } catch (IOException ex) {
                Logger.getLogger(JavaFXReadTextFile.class.getName())
                        .log(Level.SEVERE, null, ex);
            }
        }
    };

    public static void main(String[] args) {
        launch(args);
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/414160971696277913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/12/fileslines-read-text-file-returned-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/414160971696277913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/414160971696277913'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/12/fileslines-read-text-file-returned-by.html' title='Files.lines() read text file returned by JavaFX FileChooser'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/Zpv4mtzeknU/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-5082291615544447786</id><published>2015-12-06T12:10:00.001-08:00</published><updated>2015-12-06T12:29:32.883-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaFX 8 example"/><title type='text'>JavaFX FileChooser to open image file, and display on ImageView, run on Ubuntu GNOME 15.10/NetBeans 8.1</title><content type='html'>Re-test &quot;&lt;a href=&quot;http://java-buddy.blogspot.com/2013/01/use-javafx-filechooser-to-open-image.html&quot;&gt;Use JavaFX FileChooser to open image file, and display on ImageView&lt;/a&gt;&quot; on&amp;nbsp;Ubuntu GNOME 15.10/NetBeans 8.1.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hFcyIc1uRZKsD9jIeAoXrZ5Olg77F-L2etcR-aQNI2IKc6xIxZt0upadP3VuvxkJUcY4DpOcRPMoVnZSQ5Qj-GtTFTmAiSu-nfTj_c_-W_RzqEU0ApBn65_G6zOHx66J3nzvoTAUSn_x/s1600/JavaFxPixel.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hFcyIc1uRZKsD9jIeAoXrZ5Olg77F-L2etcR-aQNI2IKc6xIxZt0upadP3VuvxkJUcY4DpOcRPMoVnZSQ5Qj-GtTFTmAiSu-nfTj_c_-W_RzqEU0ApBn65_G6zOHx66J3nzvoTAUSn_x/s640/JavaFxPixel.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/Q51_dlZ55Ro&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javafxpixel;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javax.imageio.ImageIO;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaFxPixel extends Application {
    
    ImageView myImageView;
    
    @Override
    public void start(Stage primaryStage) {
        Button btnLoad = new Button(&quot;Load&quot;);
        btnLoad.setOnAction(btnLoadEventListener);
         
        myImageView = new ImageView();        
         
        VBox rootBox = new VBox();
        rootBox.getChildren().addAll(btnLoad, myImageView);
         
        Scene scene = new Scene(rootBox, 300, 300);
         
        primaryStage.setTitle(&quot;java-buddy.blogspot.com&quot;);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
    EventHandler&amp;lt;ActionEvent&amp;gt; btnLoadEventListener
    = new EventHandler&amp;lt;ActionEvent&amp;gt;(){
 
        @Override
        public void handle(ActionEvent t) {
            FileChooser fileChooser = new FileChooser();
             
            //Set extension filter
            FileChooser.ExtensionFilter extFilterJPG = 
                    new FileChooser.ExtensionFilter(&quot;JPG files (*.JPG)&quot;, &quot;*.JPG&quot;);
            FileChooser.ExtensionFilter extFilterjpg = 
                    new FileChooser.ExtensionFilter(&quot;jpg files (*.jpg)&quot;, &quot;*.jpg&quot;);
            FileChooser.ExtensionFilter extFilterPNG = 
                    new FileChooser.ExtensionFilter(&quot;PNG files (*.PNG)&quot;, &quot;*.PNG&quot;);
            FileChooser.ExtensionFilter extFilterpng = 
                    new FileChooser.ExtensionFilter(&quot;png files (*.png)&quot;, &quot;*.png&quot;);
            fileChooser.getExtensionFilters()
                    .addAll(extFilterJPG, extFilterjpg, extFilterPNG, extFilterpng);

            //Show open file dialog
            File file = fileChooser.showOpenDialog(null);
            
            try {
                BufferedImage bufferedImage = ImageIO.read(file);
                Image image = SwingFXUtils.toFXImage(bufferedImage, null);
                myImageView.setImage(image);
            } catch (IOException ex) {
                Logger.getLogger(JavaFxPixel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    };
}

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/5082291615544447786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/12/javafx-filechooser-to-open-image-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5082291615544447786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/5082291615544447786'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/12/javafx-filechooser-to-open-image-file.html' title='JavaFX FileChooser to open image file, and display on ImageView, run on Ubuntu GNOME 15.10/NetBeans 8.1'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hFcyIc1uRZKsD9jIeAoXrZ5Olg77F-L2etcR-aQNI2IKc6xIxZt0upadP3VuvxkJUcY4DpOcRPMoVnZSQ5Qj-GtTFTmAiSu-nfTj_c_-W_RzqEU0ApBn65_G6zOHx66J3nzvoTAUSn_x/s72-c/JavaFxPixel.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-109574930798888101</id><published>2015-11-11T12:17:00.000-08:00</published><updated>2015-11-11T12:27:10.417-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="WhoisClient"/><title type='text'>Query InterNIC server&#39;s whois</title><content type='html'>Last example show&amp;nbsp;&lt;a href=&quot;http://java-buddy.blogspot.com/2015/11/java-example-using-whoisclient-class.html&quot;&gt;Java example using WhoisClient class&lt;/a&gt; to query whois. Alternatively, we can query&amp;nbsp;InterNIC server&#39;s whois without&amp;nbsp;WhoisClient class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU-KiEfDJCM-qA042VTqj8wyasS91siYwKCQJiFwl3hA9_rIwKql0KBNZRP3taKQqy6E2pq3klD4E1JYnakaMc75UcM7yyd9hqw57vgKMJQASSmPt0thj4UR-2w9Jlm8TFinm2uHwnTFGj/s1600/JavaWhoIs.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU-KiEfDJCM-qA042VTqj8wyasS91siYwKCQJiFwl3hA9_rIwKql0KBNZRP3taKQqy6E2pq3klD4E1JYnakaMc75UcM7yyd9hqw57vgKMJQASSmPt0thj4UR-2w9Jlm8TFinm2uHwnTFGj/s640/JavaWhoIs.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javawhois;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class JavaWhoIs {
    
    private final static String WHO =&quot;google.com&quot;;

    private final static String WHOIS_HOST = &quot;whois.internic.net&quot;;
    private final static int WHOIS_PORT = 43;

    public static void main(String[] args) {
        int c;
        Socket socket = null; 

        String query = &quot;=&quot; + WHO + &quot;\r\n&quot;;
        byte buf[] = query.getBytes();
        
        try {
            socket = new Socket(WHOIS_HOST, WHOIS_PORT);
            InputStream in = socket.getInputStream();
            OutputStream out = socket.getOutputStream(); 

            out.write(buf); 
            out.flush();
            while ((c = in.read()) != -1) { 
                System.out.print((char) c); 
            } 
            System.out.print(&quot;\nDone\n&quot;);
        } catch (IOException ex) {
            Logger.getLogger(JavaWhoIs.class.getName()).log(Level.SEVERE, null, ex);
            System.out.print(ex.getMessage());
        } finally {
            if(socket != null){
                try {
                    socket.close();
                } catch (IOException ex) {
                    Logger.getLogger(JavaWhoIs.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
    
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/HKIIwAq-itw&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/109574930798888101/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/11/query-internic-servers-whois.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/109574930798888101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/109574930798888101'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/11/query-internic-servers-whois.html' title='Query InterNIC server&#39;s whois'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU-KiEfDJCM-qA042VTqj8wyasS91siYwKCQJiFwl3hA9_rIwKql0KBNZRP3taKQqy6E2pq3klD4E1JYnakaMc75UcM7yyd9hqw57vgKMJQASSmPt0thj4UR-2w9Jlm8TFinm2uHwnTFGj/s72-c/JavaWhoIs.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-7612842285030559712</id><published>2015-11-08T21:48:00.002-08:00</published><updated>2015-11-11T12:21:42.765-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Network Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="WhoisClient"/><title type='text'>Java example using WhoisClient class</title><content type='html'>The WhoisClient class implements the client side of the Internet Whois Protocol defined in RFC 954. To query a host you create a WhoisClient instance, connect to the host, query the host, and finally disconnect from the host. If the whois service you want to query is on a non-standard port, connect to the host at that port.&lt;br /&gt;
~&amp;nbsp;&lt;a href=&quot;https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/whois/WhoisClient.html&quot; target=&quot;_blank&quot;&gt;org.apache.commons.net.whois.WhoisClient&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package javawhoisclient;

import java.io.IOException;
import org.apache.commons.net.whois.WhoisClient;

/**
 *
 * @web http://java-buddy.blogspot.com/
 */
public class JavaWhoisClient {

    public static void main(String[] args) {
        WhoisClient whois;

        whois = new WhoisClient();

        try {
            whois.connect(WhoisClient.DEFAULT_HOST);
            System.out.println(whois.query(&quot;=google.com&quot;));
            whois.disconnect();
        } catch (IOException e) {
            System.err.println(&quot;Error I/O exception: &quot; + e.getMessage());
            return;
        }
    }

}

&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUBbc1TTezJIx0p9tlx8_8WhtDmmaRepWmBhpLjnh2fF3ksY2NVzPlCGGRdseNeE4hvIyuqtrEg9bM1sb__sQ2CQWVmF7_APwL0oTYkEnDB2daYYioMgxraxBpfmrH1v58PkFLUiWBIs6j/s1600/java+WhoisClient.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUBbc1TTezJIx0p9tlx8_8WhtDmmaRepWmBhpLjnh2fF3ksY2NVzPlCGGRdseNeE4hvIyuqtrEg9bM1sb__sQ2CQWVmF7_APwL0oTYkEnDB2daYYioMgxraxBpfmrH1v58PkFLUiWBIs6j/s640/java+WhoisClient.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGT1BEEwwvKjSF2tNNkCJza0ThnI6L6XVqh3J9AQeRvc3rv9ff6J7EY2zaBbvQIHV6doompuk4qypY9eWmaOen-gKx7PECwKsTYmjySBzOOUT9dD79mduFjIs1xGAk2ZdcFdMJvaltkf7R/s1600/java+WhoisClient+output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGT1BEEwwvKjSF2tNNkCJza0ThnI6L6XVqh3J9AQeRvc3rv9ff6J7EY2zaBbvQIHV6doompuk4qypY9eWmaOen-gKx7PECwKsTYmjySBzOOUT9dD79mduFjIs1xGAk2ZdcFdMJvaltkf7R/s640/java+WhoisClient+output.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To use&amp;nbsp;WhoisClient class in your program, you have to include library commons-net-3.3 in your code, it can be download here:&amp;nbsp;&lt;a href=&quot;https://commons.apache.org/proper/commons-net/index.html&quot; target=&quot;_blank&quot;&gt;https://commons.apache.org/proper/commons-net/index.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This video show how to download and add library commons-net-3.3 to NetBeans IDE.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/DtPz0hQcNvA&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
Next:&lt;br /&gt;
-&amp;nbsp;&lt;a href=&quot;http://java-buddy.blogspot.com/2015/11/query-internic-servers-whois.html&quot;&gt;query InterNIC server&#39;s whois without WhoisClient class&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/7612842285030559712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/11/java-example-using-whoisclient-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7612842285030559712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/7612842285030559712'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/11/java-example-using-whoisclient-class.html' title='Java example using WhoisClient class'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUBbc1TTezJIx0p9tlx8_8WhtDmmaRepWmBhpLjnh2fF3ksY2NVzPlCGGRdseNeE4hvIyuqtrEg9bM1sb__sQ2CQWVmF7_APwL0oTYkEnDB2daYYioMgxraxBpfmrH1v58PkFLUiWBIs6j/s72-c/java+WhoisClient.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-650614308495108443</id><published>2015-11-08T02:46:00.001-08:00</published><updated>2015-11-08T02:57:05.108-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="how to"/><category scheme="http://www.blogger.com/atom/ns#" term="installation"/><category scheme="http://www.blogger.com/atom/ns#" term="NetBeans"/><title type='text'>Install Netbeans 8.1 0n Ubuntu 15.10</title><content type='html'>Netbeans IDE 8.1 just released.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This video show how to download and install Netbeans IDE 8.1 on Ubuntu-GNOME 15.10&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/RZVUTCmpKVE&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;div&gt;
&lt;br /&gt;
To install Ubuntu 8.1 on Ubuntu:&lt;/div&gt;
&lt;div&gt;
- Visit&amp;nbsp;&lt;a href=&quot;https://netbeans.org/&quot; target=&quot;_blank&quot;&gt;https://netbeans.org/&lt;/a&gt; to download installer-file.&lt;/div&gt;
&lt;div&gt;
- chmod +x &amp;lt;installer-file-name&amp;gt;.&lt;/div&gt;
&lt;div&gt;
- run it with command:&lt;/div&gt;
&lt;div&gt;
./&amp;lt;installer-file-name&amp;gt; to run the installer.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The only special is to select correct path to JDK, 1:40 in the above video.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://java-buddy.blogspot.com/2015/10/install-oracle-java-8-on-ubuntu-1510.html&quot;&gt;My JDK was installed with&amp;nbsp;ppa:webupd8team&lt;/a&gt;, it&#39;s on &quot;/usr/lib/jvm/java-8-oracle&quot;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-Y-5nLi02CAhtVFwnU0OLzXE7f8qPjI4Z6Aa4b6z73q5vOEiujWL5qDQQgSj-WIH8_Op94T8oFZ2oq5txz-DH5qCDoRBzsqhsKDW-YGgFnBTqD10v0eeMeFzQHauIcSy08GaSIrpGh3Q/s1600/Install+Netbeans+on+Ubuntu.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;223&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2-Y-5nLi02CAhtVFwnU0OLzXE7f8qPjI4Z6Aa4b6z73q5vOEiujWL5qDQQgSj-WIH8_Op94T8oFZ2oq5txz-DH5qCDoRBzsqhsKDW-YGgFnBTqD10v0eeMeFzQHauIcSy08GaSIrpGh3Q/s400/Install+Netbeans+on+Ubuntu.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
If you missed the setting JDK path, you still run edit&amp;nbsp;netbeans.conf, to specify netbeans_jdkhome, or run netbeans with&amp;nbsp;--jdkhome option. (ref:&amp;nbsp;&lt;a href=&quot;http://wiki.netbeans.org/FaqRunningOnJre&quot; target=&quot;_blank&quot;&gt;http://wiki.netbeans.org/FaqRunningOnJre&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
netbeans.conf to set netbeans_jdkhome:
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/lBrD-gsEMdc&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
&lt;br /&gt;
run netbeans with --jdkhome option:
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/WaWc4Ju6IG0&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/650614308495108443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/11/install-netbeans-81-0n-ubuntu-1510.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/650614308495108443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/650614308495108443'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/11/install-netbeans-81-0n-ubuntu-1510.html' title='Install Netbeans 8.1 0n Ubuntu 15.10'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/RZVUTCmpKVE/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-4636641045454948964</id><published>2015-11-05T21:35:00.000-08:00</published><updated>2015-11-05T21:35:04.409-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JavaOne"/><title type='text'>JavaOne Keynote Highlights 10-25-2015</title><content type='html'>&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;239&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//www.slideshare.net/slideshow/embed_code/key/3qKrfMK2shKmiw&quot; style=&quot;border-width: 1px; border: 1px solid #CCC; margin-bottom: 5px; max-width: 100%;&quot; width=&quot;425&quot;&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom: 5px;&quot;&gt;
&lt;strong&gt; &lt;a href=&quot;https://www.slideshare.net/oracle/javaone-keynote-highlights-10252015-54800005&quot; target=&quot;_blank&quot; title=&quot;JavaOne Keynote Highlights 10-25-2015&quot;&gt;JavaOne Keynote Highlights 10-25-2015&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;https://www.slideshare.net/oracle&quot; target=&quot;_blank&quot;&gt;Oracle&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;
&lt;/center&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/4636641045454948964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/11/javaone-keynote-highlights-10-25-2015.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/4636641045454948964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/4636641045454948964'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/11/javaone-keynote-highlights-10-25-2015.html' title='JavaOne Keynote Highlights 10-25-2015'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-3366015194616859545</id><published>2015-11-05T20:19:00.003-08:00</published><updated>2015-11-05T20:19:45.418-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java I/O"/><category scheme="http://www.blogger.com/atom/ns#" term="nio"/><category scheme="http://www.blogger.com/atom/ns#" term="reference"/><title type='text'>Java I/O, NIO and NIO.2</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3oUd6LkOvavx2vl_8_ij6j_0aBvLMEvH9UQX96kIbd_PbteticEALl7iY9ORZx6o5i-DhVUTLeiccE0TyvHzgf_iMEdvJnFfwMwKrZitZsB7zrF4IQ9RTCJmmtcAdFKTEFB3b2rr43np-/s1600/Java+IO%252C+NIO+and+NIO.2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3oUd6LkOvavx2vl_8_ij6j_0aBvLMEvH9UQX96kIbd_PbteticEALl7iY9ORZx6o5i-DhVUTLeiccE0TyvHzgf_iMEdvJnFfwMwKrZitZsB7zrF4IQ9RTCJmmtcAdFKTEFB3b2rr43np-/s320/Java+IO%252C+NIO+and+NIO.2.jpg&quot; width=&quot;210&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1484215664/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1484215664&amp;amp;linkCode=as2&amp;amp;tag=pointe&amp;amp;linkId=BAMKBBOZ3DVN2PUC&quot; rel=&quot;nofollow&quot;&gt;Java I/O, NIO and NIO.2&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=pointe&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1484215664&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Java I/O, NIO, and NIO.2 is a power-packed book that accelerates your mastery of Java&#39;s various I/O APIs. In this book, you&#39;ll learn about classic I/O APIs (File, RandomAccessFile, the stream classes and related types, and the reader/writer classes). Next, you&#39;ll learn about NIO&#39;s buffer, channel, selector, regular expression, charset, and formatter APIs. Finally, you&#39;ll discover NIO.2&#39;s offerings in terms of an improved file system interface, asynchronous I/O, and the completion of socket channel functionality.&lt;br /&gt;
&lt;br /&gt;
After reading and using thi book, you&#39;ll gain the accelerated knowledge and skill level to really build applications with efficient data access, especially for today&#39;s cloud computing streaming data needs.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What you’ll learn&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;How to set permissions and more with the classic File class&lt;/li&gt;
&lt;li&gt;How to build a flat file database with RandomAccessFile&lt;/li&gt;
&lt;li&gt;Get to know the byte array, file, filter, and other kinds of streams&lt;/li&gt;
&lt;li&gt;Master serialization and externalization&lt;/li&gt;
&lt;li&gt;Discover character streams and their associated writers/readers&lt;/li&gt;
&lt;li&gt;Tour the buffer APIs&lt;/li&gt;
&lt;li&gt;Work with channels to transfer buffers to and from I/O services&lt;/li&gt;
&lt;li&gt;Find out about selectors and readiness selection&lt;/li&gt;
&lt;li&gt;Master regular expressions&lt;/li&gt;
&lt;li&gt;Discover charsets and their association with Java&#39;s String&amp;lt; class&lt;/li&gt;
&lt;li&gt;Take advantage of the formatter API to create formatted output&lt;/li&gt;
&lt;li&gt;How to customize the formatter API&lt;/li&gt;
&lt;li&gt;Explore the improved file system interface&lt;/li&gt;
&lt;li&gt;Discover asynchronous I/O and its association with futures and completion handlers&lt;/li&gt;
&lt;li&gt;Encounter socket channel improvements, including multicasting&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Who this book is for&lt;/b&gt;&lt;br /&gt;
This book is for those experienced with Java, beyond the fundamentals.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Table of Contents&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Part 1: Getting Started with I/O&lt;/b&gt;&lt;br /&gt;
Chapter 1: I/O Basics and APIs&lt;br /&gt;
&lt;b&gt;Part 2: Classic I/O APIs&lt;/b&gt;&lt;br /&gt;
Chapter 2: File&lt;br /&gt;
Chapter 3: RandomAccessFile&lt;br /&gt;
Chapter 4: Streams&lt;br /&gt;
Chapter 5: Writers and Readers&lt;br /&gt;
&lt;b&gt;Part 3: New I/O APIs&lt;/b&gt;&lt;br /&gt;
Chapter 6: Buffers&lt;br /&gt;
Chapter 7: Channels&lt;br /&gt;
Chapter 8: Selectors&lt;br /&gt;
Chapter 9: Regular Expressions&lt;br /&gt;
Chapter 10: Charsets&lt;br /&gt;
Chapter 11: Formatter and Scanner&lt;br /&gt;
&lt;b&gt;Part 4: More New I/O APIs&lt;/b&gt;&lt;br /&gt;
Chapter 12: File System APIs&lt;br /&gt;
Chapter 13: Asynchronous I/O&lt;br /&gt;
Chapter 14: Additional NIO.2 APIs&lt;br /&gt;
Appendix A: Answers to Review Exercises&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;amp;OneJS=1&amp;amp;Operation=GetAdHtml&amp;amp;MarketPlace=US&amp;amp;source=ac&amp;amp;ref=tf_til&amp;amp;ad_type=product_link&amp;amp;tracking_id=pointe&amp;amp;marketplace=amazon&amp;amp;region=US&amp;amp;placement=1484215664&amp;amp;asins=1484215664&amp;amp;linkId=WU7YI2LAUCZ4IYNU&amp;amp;show_border=true&amp;amp;link_opens_in_new_window=true&quot; style=&quot;height: 240px; width: 120px;&quot;&gt;
&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/3366015194616859545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/11/java-io-nio-and-nio2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3366015194616859545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/3366015194616859545'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/11/java-io-nio-and-nio2.html' title='Java I/O, NIO and NIO.2'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3oUd6LkOvavx2vl_8_ij6j_0aBvLMEvH9UQX96kIbd_PbteticEALl7iY9ORZx6o5i-DhVUTLeiccE0TyvHzgf_iMEdvJnFfwMwKrZitZsB7zrF4IQ9RTCJmmtcAdFKTEFB3b2rr43np-/s72-c/Java+IO%252C+NIO+and+NIO.2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1661517518925762010.post-1421613506785760384</id><published>2015-10-29T21:16:00.000-07:00</published><updated>2015-10-29T21:16:02.661-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java-gnome"/><title type='text'>Install java-gnome on Ubuntu 15.10, and first try.</title><content type='html'>The &lt;a href=&quot;http://java-gnome.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;java-gnome User Interface Library&lt;/a&gt; is a Java bindings for GTK and GNOME. To install it on Ubuntu, enter the command in Terminal:&lt;br /&gt;
&lt;b&gt;$&amp;nbsp;sudo apt-get install libjava-gnome-java&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/mgu_8jPccY8&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
(reference:&amp;nbsp;&lt;a href=&quot;http://java-gnome.sourceforge.net/get/ubuntu.php&quot; target=&quot;_blank&quot;&gt;http://java-gnome.sourceforge.net/get/ubuntu.php&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
First try:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMsJeJMtUbnGqDmU5KREQmbKxfW2Vc_LRDw6ugqppgeYumvCiYpSvWjijTDqhow3NrSgGZzKeU7FitJmL3HBWDIQY0QZwhRz2ptlT3cXfcCYZ1z_kfP9S8PXfFOb33LF3qpUuXd6puPIP3/s1600/ExamplePressMe.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;111&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMsJeJMtUbnGqDmU5KREQmbKxfW2Vc_LRDw6ugqppgeYumvCiYpSvWjijTDqhow3NrSgGZzKeU7FitJmL3HBWDIQY0QZwhRz2ptlT3cXfcCYZ1z_kfP9S8PXfFOb33LF3qpUuXd6puPIP3/s320/ExamplePressMe.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a my first example&amp;nbsp;ExamplePressMe.java (copt from &lt;a href=&quot;http://java-gnome.sourceforge.net/doc/examples/button/ExamplePressMe.html&quot; target=&quot;_blank&quot;&gt;HERE&lt;/a&gt;), under trial directory ~/java-gnome-works.
&lt;br /&gt;
&lt;pre class=&quot;brush: java&quot;&gt;/*
 * ExamplePressMe.java
 *
 * Copyright (c) 2006-2008 Operational Dynamics Consulting Pty Ltd
 *
 * The code in this file, and the library it is a part of, are made available
 * to you by the authors under the terms of the &quot;GNU General Public Licence,
 * version 2&quot; See the LICENCE file for the terms governing usage and
 * redistribution.
 */
package button;

import org.gnome.gdk.Event;
import org.gnome.gtk.Button;
import org.gnome.gtk.Gtk;
import org.gnome.gtk.Label;
import org.gnome.gtk.VBox;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;

/**
 * A simple Window with a Label and a Button in it. Demonstrates the basics of
 * initializing GTK, packing Widgets into Containers, and hooking up signals.
 * 
 * This example has been around, in one form or another, since the very
 * beginnings of java-gnome. If you&#39;re just starting out with GTK and GNOME
 * don&#39;t worry; we started here too.
 * 
 * @author Andrew Cowie
 * @since 4.0.0
 */
public class ExamplePressMe
{
    public static void main(String[] args) {
        final Window w;
        final VBox x;
        final Label l;
        final Button b;

        /*
         * Initialize GTK. You MUST call this to load the library before
         * trying to use any other elements provided by java-gnome.
         */

        Gtk.init(args);

        /*
         * Create a top level Window. It&#39;s the Container around which the
         * window manager draws decorations such as a title bar, minimize and
         * close buttons, resize edges, etc.
         */

        w = new Window();

        /*
         * Since a Window is a Bin, it can only have one child Widget. That&#39;s
         * probably not very useful in most cases. To take that one slot and
         * turn it into many, we use a VBox, a Container that will stack its
         * children vertically.
         */

        x = new VBox(false, 3);

        /*
         * Create a Label with some text describing the Button that will
         * follow, then add it to the VBox.
         */

        l = new Label(&quot;Go ahead:\nMake my day&quot;);
        x.add(l);

        /*
         * Create our Button, with a nice explicit bit of text labelling it
         * and what you&#39;re to do.
         */

        b = new Button(&quot;Press me!&quot;);
        x.add(b);

        /*
         * Now the magic part. Just sitting there, the Button won&#39;t do
         * anything. You need to hook up a &quot;signal handler&quot; to deal with the
         * &#39;clicked&#39; signal. This is how we do it in java-gnome.
         * 
         * Button.Clicked is a Java interface. You create an instance of it to
         * do what you want when the callback happens, and then pass it to the
         * Button&#39;s connect() method.
         * 
         * The onClicked() method is what is required by the Button.Clicked
         * interface. Most IDEs will prompt you asking if you want to &quot;Add
         * unimplemented methods?&quot; You bet! And ta-da! You have exactly the
         * signature you need to implement a &#39;clicked&#39; signal handler.
         * 
         * Since we declared b as final we can use it in the anonymous nested
         * class (yet *another* reason that final is worth using). If the
         * situation were otherwise, then the source parameter can be used to
         * find out what Button was clicked.
         */

        b.connect(new Button.Clicked() {
            public void onClicked(Button source) {
                System.out.println(&quot;I was clicked: &quot; + b.getLabel());
            }
        });

        /*
         * Now we pack the VBox into our Window, set the Window&#39;s title, and
         * invoke the command to realize everything onto the screen.
         */

        w.add(x);
        w.setTitle(&quot;Hello World&quot;);
        w.showAll();

        /*
         * We would be be done except for one last detail. Closing a Window
         * does not terminate the application. If that&#39;s what you want (and we
         * do indeed want that here) then you need to hook up a handler to do
         * something when the &#39;delete-event&#39; signal is emitted.
         * 
         * Again, the method here implements the interface.
         */

        w.connect(new Window.DeleteEvent() {
            public boolean onDeleteEvent(Widget source, Event event) {
                Gtk.mainQuit();
                return false;
            }
        });

        /*
         * Now we&#39;re ready to run the main loop. The signals we&#39;ve hooked up
         * handlers for above won&#39;t be emitted until the user does something,
         * but no events will be processed until the main loop is running;
         * that&#39;s where the signals will come from. This call blocks. You have
         * finished setting things up and now it&#39;s up to your signal handlers
         * to carry out the program&#39;s logic in response to the user&#39;s actions;
         * the essence of event-driven programming.
         */

        Gtk.main();
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Make a tests directory to hold the output.&lt;br /&gt;
&lt;br /&gt;
Enter the command to compile the java code with java-gnome.&lt;br /&gt;
&lt;b&gt;$ javac -classpath /usr/share/java/gtk-4.1.jar -d tests ExamplePressMe.java&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Run it:&lt;br /&gt;
&lt;b&gt;$ java -classpath /usr/share/java/gtk-4.1.jar:tests button.ExamplePressMe&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Where /usr/share/java/gtk-4.1.jar is the installed gtk-4.1.jar.&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/sHGkTKEFOGM&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/center&gt;
&lt;br /&gt;
(reference: &lt;a href=&quot;http://java-gnome.sourceforge.net/README.html&quot; target=&quot;_blank&quot;&gt;http://java-gnome.sourceforge.net/README.html&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-buddy.blogspot.com/feeds/1421613506785760384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-buddy.blogspot.com/2015/10/install-java-gnome-on-ubuntu-1510-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1421613506785760384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1661517518925762010/posts/default/1421613506785760384'/><link rel='alternate' type='text/html' href='http://java-buddy.blogspot.com/2015/10/install-java-gnome-on-ubuntu-1510-and.html' title='Install java-gnome on Ubuntu 15.10, and first try.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02036390354033315722</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/mgu_8jPccY8/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>