Java

How to get a SubString of a String in Java

Submitted by donbermoy on
This is a tutorial in which we are going to create a program that gets substring of a string in java. We all know that a substring is a part of a sentence or a string. Java String class provides substring method with some overloaded parameter. So, now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of subString.java. 2. Import java.lang package because in this library, substring class is there.

How to Generate a Random Number in Java

Submitted by donbermoy on
In this tutorial, we will going to create a program that generates a random number using Java. We will just use the Math.random() function which returns a random number between 0.0 and 1.0 Now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of randomNumber.java. 2. Import javax.swing package.

How to get the extension of a file using Java

Submitted by donbermoy on
Today, I will teach you how to create a program that get the extension of a file using java. For example if we input a text file of .txt file extension then the output will be .txt. So, now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of extensionFile.java. 2. Import java.io package.

How to Check if an Inputted Year is a Leap Year using Java GUI

Submitted by donbermoy on
In this tutorial, i will teach you how to check if an inputted year as leap year or not. Hence we already know that leap year has 366 days instead of the normal 365 days. Leap years occur every 4 years. And this fact is our formula in finding a leap year using Java GUI. So, now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of leapYear.java. 2. Import javax.swing package. Hence we will use a GUI (Graphical User Interface) here like the inputting the year.

How to Create a Log File in Java

Submitted by donbermoy on
Today, I will teach you how to create a log file in java. We all know that a file is a list actions that occurred in which a program records events, such as user access or data manipulation as they occur to serve as an audit trail or warning message. So, now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of logFile.java. 2. Import java.io package. Hence we will use an input/output in creating files and for the IOException class.

How to Insert a Text in a Specified Position of JTextArea Component in Java GU

Submitted by donbermoy on
This is a continuation of my other tutorials entitled JTextArea Component in Java GUI and Set Font and Color to Text of JTextArea Component in Java GUI. But in this tutorial, i will teach you how to insert a text in a specified position of JTextArea component using Java GUI. 1.

Set Font and Color to Text of JTextArea Component in Java GUI

Submitted by donbermoy on
This is a continuation of my other tutorial entitled JTextArea Component in Java GUI. This tutorial will teach you how to set/select font and color for the JTextArea or JTextField component. 1. First and foremost, Open JCreator or NetBeans and make a java program with a file name of jTextArea.java. When you click the link above, copy first all the code there. import java.awt.*; import javax.swing

JTextArea Component in Java GUI

Submitted by donbermoy on
This is a tutorial on how to use the JTextArea Component of Java. JTextArea is different from JTextField. Unlike JTextField that will only be used for one line of text, the JTextArea Component can hold more than one line to display text. So, now let's start this tutorial! 1. Open JCreator or NetBeans and make a java program with a file name of jTextArea.java. 2.

How to Zip your File using Java

Submitted by donbermoy on
Today, I will teach you how to create a program that will zip your file using Java. We all know that zip is a popular compression format that also contains one or more files that have been compressed into the ZIP format. So, now let's start this tutorial! 1. Open Notepad. Encode any data in there and save it to the same folder with your java program and named it as READ FIRST.txt (Note: you can

How to Delete Files using Java

Submitted by donbermoy on
In this tutorial, we will create a program that can delete files using Java. We are done with creating files, appending, and reading data inside of a file. So, now let's start this tutorial! 1. Open Notepad. Encode any data in there and save it to the same folder with your java program and named it as data.txt. 2. Open JCreator or NetBeans and make a java program with a file name of deleteFiles