How to convert Array to List in java?

How to convert Array to List in java?

Below code example show how to convert an array to List in java. To convert array based data into list, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list. OUTPUT: TOM JACK JILL JANE

Read More

How to convert an array into a collection object?

How to convert an array into a collection object?

Below java code example show how to convert an array into a Collection object. To convert array based data into list / collection, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list / collection. OUTPUT: TOM JACK JILL JANE

Read More

How to remove line or lines from a file in java?

How to remove line or lines from a file in java?

Below java code shows how to remove line from file /**************************************************************************************** * Created on 10-2011Copyright(c) http://kodehelp.com All Rights Reserved. ****************************************************************************************/ package com.kodehelp.javaio; import java.io.*; /** * Created by http://kodehelp.com * Date: 10/3/11 */ public class RemoveALine { public static void main(String args[]){ try { File inputFile = new File(“/conf.ini”); if (!inputFile.isFile()) { System.out.println(“Parameter is not …

Read More

How to get list of files using FileFilter class in java?

How to get list of files using FileFilter class in java?

Below java code shows how to get list of files using FileFilter class. FileFilter is an abstract class used by JFileChooser for filtering the set of files shown to the user. A FileFilter can be set on a JFileChooser to keep unwanted files from appearing in the directory listing.   Reference: Java Docs

Read More

Symbols used in Syntax of Scala Language

Scala Lang has many different symbols used in its syntax. Below is the list of symbols and its use in Scala language. “->” arrow symbol in Scala syntax returns a two element tuple containing the key and value. You can use this symbol as shown in below example- Map(1->”Allan”, 2->”Bob”) (1).->(“A) “_” underscore symbol  in scala syntax is intended as …

Read More

How to Install Scala 2.9.1 on Linux (Ubuntu 11.04) ?

To install Scala on Linux you need to get scala on your Linux machine. You can get Scala by below two methods : 1) Default Scala version available on your Linux box by typing below command sudo apt-get install scala 2) If you want to get the latest version of the scala below are the …

Read More

Java Code Example for Hello World Program

Every beginner who starts programming in any language writes Hello World Program. Java Programmer is not exception for Hello World program. Below is the java version of Hello World Program. To start with Hello World java program you need to create HelloWorld.java file, Once you created file write class HelloWorld. The name of class and …

Read More

How to use a FileChannel to read data into a Buffer in java code?

Below Java code shows how to use FileChannel to read data into buffer. This is done by following below steps : Create FileInputStream for the file to be read Create FileChannel from FileInputStream Create ByteBuffer as channel reads data into buffer and set the limit of ByteBuffer. Read data from channel to byteBuffer To read …

Read More