Karthikeya Boyini has Published 2192 Articles

Search an element of ArrayList in Java

karthikeya Boyini

karthikeya Boyini

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

9K+ Views

An element in an ArrayList can be searched using the method java.util.ArrayList.indexOf(). This method returns the index of the first occurance of the element that is specified. If the element is not available in the ArrayList, then this method returns -1.A program that demonstrates this is given as follows −Example Live ... Read More

ftp_close() function in PHP

karthikeya Boyini

karthikeya Boyini

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

124 Views

The ftp_close() function closes an FTP connection.Syntaxftp_close(con);Parameterscon − The connection to close.ReturnThe ftp_close() function returns TRUE on success or FALSE on failureExampleThe following is an example that login to a connection, works in it to change the directory and then connection is closed −

ftp_delete() function in PHP

karthikeya Boyini

karthikeya Boyini

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

165 Views

The ftp_delete() function is used to delete a file on the FTP server.Syntaxftp_delete(con,myfile);Parameterscon − The FTP connectionmyfile − The file to be deletedReturnThe ftp_delete() function returns TRUE on success or FALSE on failureExampleThe following is an example to delete a file −

Remove all values from TreeMap in Java

karthikeya Boyini

karthikeya Boyini

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

465 Views

Use the clear() method to remove all values from TreeMap.Let us first create a TreeMap −TreeMap m = new TreeMap();Add some elements to the TreeMap −m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Let us now remove all the values −m.clear();The following is an example ... Read More

Java Program to format to 2 decimal places in a 10-character field

karthikeya Boyini

karthikeya Boyini

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

185 Views

To format, use the Formatter class. Import the following package to work with the Formatter class in Java −import java.util.Formatter;Create a Formatter object and format to 2 decimal places in a 10-character field −Formatter f = new Formatter(); System.out.println(f.format("%10.2e", 3989.7886));The following is the complete example −Example Live Demoimport java.util.Formatter; public class ... Read More

Get file extension name in Java

karthikeya Boyini

karthikeya Boyini

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

666 Views

The file extension is the suffix that is attached to the computer file and it denotes the format of the file. A program that demonstrates getting the file extension name is given as follows −Example Live Demoimport java.io.File; public class Demo {    private static String fileExtension(File file) {     ... Read More

ftp_fget() function in PHP

karthikeya Boyini

karthikeya Boyini

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

270 Views

The ftp_fget() function is used to downloads file from the FTP server and save it into an open local fileSyntaxftp_fget(con, open_file, server_file, mode, startpos);Parameterscon − The FTP connectionopen_file − A file where the data is storedserver_file − The server file to downloadmode − The transfer modestartpos − The position to ... Read More

Get the system properties from RuntimeMXBean in Java

karthikeya Boyini

karthikeya Boyini

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

365 Views

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();To get the system properties, use the getSystemProperties() method −System.out.println("System properties from RuntimeMXBean: "+runtimeMX.getSystemProperties());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 ... Read More

Remove all elements from TreeSet in Java

karthikeya Boyini

karthikeya Boyini

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

505 Views

Use the clear() method to remove all elements from TreeSet.First, create a TreeSet and add elements −TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); set.add("27"); set.add("89"); set.add("57");Now, remove all the elements −set.clear();The following is an example to remove all elements from TreeSet −Example Live Demoimport java.util.*; public class Demo { ... Read More

ftp_get_option() function in PHP

karthikeya Boyini

karthikeya Boyini

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

145 Views

The ftp_get_option() function returns runtime options of the FTP connection.Syntaxftp_get_option(con, option);Parameterscon − The FTP connection.option − The runtime option to return.The following are the possible values −FTP_TIMEOUT_SEC - The timeout used for network operationsFTP_AUTOSEEK - Returns TRUE if this option is on, FALSE otherwiseReturnThe ftp_get_option() function returns the value on ... Read More

Advertisements