Karthikeya Boyini has Published 2193 Articles

Display today’s date in Java with SimpleDateFormat

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

267 Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;To get the date, use the format() method as shown below. Firstly, set the date format −Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MM/yyyy");Now, we will get the date −simpleformat.format(cal.getTime())The following is the complete example −Example Live Demoimport java.text.SimpleDateFormat; ... Read More

Implement a stack from a LinkedList in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

3K+ Views

A stack can be implemented using a LinkedList by managing the LinkedList as a stack. This is done by using a class Stack which contains some of the Stack methods such as push(), top(), pop() etc.A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; class Stack { ... Read More

ftp_pwd() function in PHP

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

74 Views

The ftp_pwd() function returns the present working directory i.e. the current directory.Syntaxftw_pwd(con)Parameterscon − The FTP connectionReturnThe ftp_pwd() function returns TRUE on success or FALSE on failure.ExampleThe following is an example −

Check for file or directory in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

490 Views

The method java.io.File.isFile() is used to check whether the given file is an existing file in Java. Similarly, the method java.io.File.isDirectory() is used to check whether the given file is a directory in Java. Both of these methods require no parameters.A program that demonstrates this is given as follows −Examplepublic ... Read More

Display seconds with SimpleDateFormat(“s”) in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

285 Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“s”) to display seconds in one-digit.Format f = new SimpleDateFormat(”s”);Now, get the seconds in a string.String strSeconds = f.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public ... Read More

Determine if file or directory exists in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

7K+ Views

The method java.io.File.exists() is used to check whether a file or a directory exists or not. This method returns true if the file or directory specified by the abstract path name exists and false if it does not exist.A program that demonstrates this is given as follows −Exampleimport java.io.File; public ... Read More

NavigableSet Class lower() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

93 Views

The lower() method of NavigableSet returns the greatest element strictly less than the given element i.e. 35 here −lower(35);The following is an example to implement the lower() method in Java −Example Live Demoimport java.util.NavigableSet; import java.util.TreeSet; public class Demo { public static void main(String[] args) { ... Read More

Parse and format to arbitrary radix <= Character.MAX_RADIX in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

288 Views

Let us set a radix here as.// radix int r = 32;Include the radix here as a BigInteger constructor.BigInteger one = new BigInteger("vv", r);Now get its string representation −String strResult = one.toString(radix);The following is an example −Example Live Demoimport java.math.*; public class Demo { public static void main(String[] ... Read More

ftp_raw() function in PHP

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

83 Views

The ftp_raw() function is used to sends raw command to the FTP server.Syntaxftp_raw(con, command)Parameterscon − The FTP connectioncommand − The command to executeReturnThe ftp_raw() function returns the server's response as an array of strings.ExampleThe following is an example −

Java Program to get name of specified file or directory

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

353 Views

The name of the specified file or directory can be obtained using the method java.io.File.getName(). The getName() returns the name of the file or the directory and it requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void ... Read More

Advertisements