Home » Featured Tutorials

Featured Tutorials

Heads of Tutorial Trails

Simple 3D Graphics using JavaFX

Simple3D Graphics JavaFX rewrite of my first article using Swing Simple 3D graphics using Java was my first article using Swing UI. As you know JavaFX is the replacement for Swing. In this article I will talk about JavaFX a bit more than the app itself because it was a conversion. This is not only a JavaFX app it’s a JavaFX FXML app. So like Android apps there are two ways to define the UI. You can build it with code within class  definitions and constructors. Or you can define the UI with XML. In this case its FXML for Java FX XML. SceneBuilder and NetBeans You can define the FXML with a text/code editor. This would be painful and you would have to know FXML fairly well and do a lot of looking things up. Or you can download SceneBuilder from Gluon. You can use the FXML generated by ...

Profiling Java Efficiency

Profiling without an  IDE with Java Think you need an IDE or a paid IDE to profile? Think again. I explain in this post how to do this with the basic Java language. You will find some interesting results in the very simple test case that I made up for this article. Later I will try to come back and upgrade this article to test a couple of other methods mentioned and other types of objects. How to use Java to determine the size of something. How to Get the Size of an Object in Java is an article that talks about using getObjectSize(Object objectToSize) of Instrumentation interface It seems this interface was created to work with bytecode but it can be used to get an estimated object size. In his article he states. Minimum object size is 16 bytes for modern 64-bit JDK since the object has 12...

Local Data Storage 6 – Reading and Writing XML data files using Java

XML Data Files Working with Java and Files Tutorial Trail Serialize Objects to Files Serialize XML to Files In this post I will show you how to read and write data types in simple xml data files using XML DOM. DOM means Document Object Model. We are mainly concerned here with reading and writing some data of the same types we have been working with in previous articles. So i.e. xml data files <some document> <some element> <some data name=value/> <some data name="value"/> <some data> some text </some data> </some element> </some document> XML Documents XML document can be more complex with other parts to parse. In this, we have a document root which has as children which have children which have attributes which contain the data we want ...

Local Data Storage 5 – Reading and Writing Serialized Objects to a File

Reading and Writing Objects to files or streams is fairly straight forward. Here is a working example. There are a few things to know. Use serialver.exe to create a serial id number for the class. A class must implement Serializable interface and should use @serial tag in Javadoc comments. A cryptic coded file is created which is not very editable or readable. In a later article I will talk about serializing objects to xml streams and files.

Local Data Storage 4 – Java Fixed Width Text files using row, col type storage.

This article demonstrates using a fixed field width | delimited text file similar to a spread sheet. You can store and retrieve various data types in give row,col cells. It expands columns if new data is longer than the cell. It does not add new columns or rows however and if you try to access columns or rows that are no there you get out of bounds errors. In the example I show a survey note book sheet that we use in mapping caves. A future version of this might calculate variables that would be used in cave mapping and add them to the sheet. This could also be used for mapping things above ground.

Local Data Storage 3 – Reading and Writing Property Files using Java

I show you how to read and write your own property file which contains name=value pairs. Java comes with a Properties object to do this exact thing and I will write an article about that object later. Or expand this article to include an example. This article is another example of using a delimiter and in this case it is = symbol. Later I will upgrade this to include new line as delimiter to handle long strings.

Local Data Storage 1 – Reading and Writing files using Java

Simple examples for writing and reading to and from a text file line by line. Write, Read and Append. In Java we not only use FileWriter and FileReader but also BufferedWriter and BufferedReader to speed up reading and writing in just about all cases.