Samual Sam has Published 2310 Articles

Create directories recursively in Java

Samual Sam

Samual Sam

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

178 Views

The method java.io.File.mkdirs() is used to create the specified directories, including the necessary parent directories. This method requires no parameters and it returns true on the success of the directories creation or false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {   ... Read More

ftp_put() function in PHP

Samual Sam

Samual Sam

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

281 Views

The ftp_put() function uploads a file to the FTP server.Syntaxftp_put(con, remote_file, local_file, mode, beg_pos);Parameterscon − The FTP connectionremote_file − The file path to upload tolocal_fil − The path of the file to uploadmode − The transfer mode. The following are the possible value −FTP_ASCII, orFTP_BINARYbeg_pos − The position to start ... Read More

Display hour with SimpleDateFormat(“hh”) in Java

Samual Sam

Samual Sam

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

289 Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“hh”) to display hour −Format f = new SimpleDateFormat("hh");Now, get the hour in a string −String strHour = 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

Traverse a collection of objects using the Enumeration Interface in Java

Samual Sam

Samual Sam

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

1K+ Views

All the elements in a collection of objects can be traversed using the Enumeration interface. The method hasMoreElements( ) returns true if there are more elements to be enumerated and false if there are no more elements to be enumerated. The method nextElement( ) returns the next object in the ... Read More

ftp_quit() function in PHP

Samual Sam

Samual Sam

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

99 Views

The ftp_quit() function is an alias to ftp_close(). It closes an FTP connection.Syntaxftp_quit(con);Parameterscon − The connection to close.ReturnThe ftp_quit() 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 the connection is closed ... Read More

Parsing and Formatting a Byte Array into Decimal in Java

Samual Sam

Samual Sam

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

2K+ Views

Set a BigInteger object.BigInteger one;Now, create a ByteArray −byte byteArr[] = new byte[] { 0x1, 0x00, 0x00 }; one = new BigInteger(byteArr);For Decimal, we have used toString() method without any parameter value.String strResult = one.toString();The following is an example −Example Live Demoimport java.math.*; public class Demo { public ... Read More

How to use subSet() method of Java NavigableSet Class

Samual Sam

Samual Sam

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

164 Views

Use the subset() method to get elements from a limit. At first, create NavigableSet and add elements −NavigableSet set = new TreeSet(); set.add(10); set.add(25); set.add(40); set.add(55); set.add(70); set.add(85);Now, use the subset() method −set.subSet(40, 85)The following is an example to implement subset() method of Java NaviagbleSet class −Example Live Demoimport java.util.NavigableSet; import ... Read More

Java Program to get name of parent directory

Samual Sam

Samual Sam

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

257 Views

The name of the parent directory of the file or directory can be obtained using the method java.io.File.getParent(). This method returns the parent directory pathname string or null if there is no parent named.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {   ... Read More

Convert BigInteger into another radix number in Java

Samual Sam

Samual Sam

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

1K+ Views

First, create a BigInteger.BigInteger val = new BigInteger("198");Let us convert it to Binary, with radix as 2.val.toString(2);Convert it to Octal, with radix as 8.val.toString(8);Convert it to HexaDecimal, with radix as 16.val.toString(16);The following is an example −Example Live Demoimport java.math.BigInteger; public class Main { public static void main(String[] args) ... Read More

ftp_rawlist() function in PHP

Samual Sam

Samual Sam

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

112 Views

The ftp_rawlist() function displays the list of files with file information from a specified directorySyntaxftp_rawlist(conn, dir, recursive);Parametersconn − The FTP connectiondir − The directory pathrecursive − Sends a "LIST" command to the server by default.ReturnThe ftp_rawlist() function returns an array where each element corresponds to one line of text.ExampleThe following ... Read More

Advertisements