Samual Sam has Published 2310 Articles

Displaying at most 10 characters in a string in Java

Samual Sam

Samual Sam

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

497 Views

To display at most 10 characters in a string, work with the Formatter class.Import the following package for Formatter class in Java −import java.util.Formatter;Create a new Formatter object −Formatter f = new Formatter();Let us now display at most 10 characters in a string −f = new Formatter(); System.out.println("Displaying at most ... Read More

Remove specified element from TreeSet in Java

Samual Sam

Samual Sam

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

243 Views

Use the remove() method to remove specified elements from TreeSet.At first, create a TreeSet and add elements −TreeSet set = new TreeSet(); set.add("34"); set.add("12"); set.add("67"); set.add("54"); set.add("76"); set.add("49");Now, remove the specified element i.e. 34 here −set.remove("34")The following is an example to remove specified element from TreeSet −Example Live Demoimport java.util.*; public ... Read More

ftp_fput() function in PHP

Samual Sam

Samual Sam

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

168 Views

The ftp_fget() function is used to upload from an open file and saves it to a file on the FTP server.Syntaxftp_fput(con, remote_file, open_file, mode, startpos);Parameterscon − The FTP connectionremote_file − The file path to upload toopen_file − The open local filemode − The transfer modestartpos − The position to begin ... Read More

Get Absolute path of a file in Java

Samual Sam

Samual Sam

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

2K+ Views

The method java.io.File.getAbsolutePath() is used to obtain the absolute path of a file in the form of a string. This method requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File ... Read More

Get the JVM uptime from RuntimeMXBean in Java

Samual Sam

Samual Sam

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

382 Views

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine −RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();Let us get the JVM uptime using the getUptime() method −runtimeMX.getUptime()The following is an example −Example Live Demoimport java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class Demo { public static void main(String ... Read More

File Path with double slash in Java

Samual Sam

Samual Sam

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

1K+ Views

The double slash in the file path is required as to create the ’\’ character , another ‘\’ needs to be added to escape it. A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {     ... Read More

Get Boot path from RuntimeMXBean in Java

Samual Sam

Samual Sam

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

189 Views

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();To get the boot path, use the getBootClassPath() method −runtimeMX.getBootClassPath()The following is an example −Example Live Demoimport java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class Demo {    public static void main(String args[]) throws Exception { ... Read More

Search a particular element in a LinkedList in Java

Samual Sam

Samual Sam

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

226 Views

A particular element can be searched in a LinkedList using the method java.util.LinkedList.indexOf(). This method returns the index of the first occurance of the element that is searched. If the element is not available in the LinkedList, then this method returns -1.A program that demonstrates this is given as follows ... Read More

ftp_login() function in PHP

Samual Sam

Samual Sam

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

123 Views

The ftp_login() function allows you to log in to the FTP connection.Syntaxftp_login(con, user_name, password);Parameterscon − The FTP connectionuser_name − The user name to log inpassword − The password to loginReturnThe ftp_login() function returns TRUE on success or FALSE and warning on failure.ExampleThe following is an example −Read More

Display month by name and number in Java

Samual Sam

Samual Sam

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

454 Views

Use the ‘b’ conversion character for month name in Java.Use the ‘m’ conversion character for month number in Java.Here, we are using Formatter and Calendar class, therefore import the following packages.import java.util.Calendar; import java.util.Formatter;The following is an example to display month name and number −Example Live Demoimport java.util.Calendar; import java.util.Formatter; public ... Read More

Advertisements