Karthikeya Boyini has Published 2383 Articles

Java Program to rename a file or directory

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

The method java.io.File.renameTo() is used to rename a file or directory. This method requires a single parameter i.e. the name that the file or directory is renamed to and it returns true on the success of the renaming or false otherwise.A program that demonstrates this is given as follows −Example Live ... Read More

Remove a range of elements from a LinkedList in Java

karthikeya Boyini

karthikeya Boyini

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

290 Views

A range of elements can be removed from a LinkedList by using the method java.util.LinkedList.clear() along with the method java.util.LinkedList.subList(). A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo { public static void main(String[] args) { ... Read More

Bandwidth Delay Product

karthikeya Boyini

karthikeya Boyini

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

8K+ Views

Bandwidth delay product is a measurement of how many bits can fill up a network link. It gives the maximum amount of data that can be transmitted by the sender at a given time before waiting for acknowledgment. Thus it is the maximum amount of unacknowledged data.MeasurementBandwidth delay product is ... Read More

Create a new empty file in Java

karthikeya Boyini

karthikeya Boyini

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

10K+ Views

A new empty file with the required abstract path name can be created using the method java.io.File.createNewFile(). This method requires no parameters and it returns true if the file is newly created and it did not exist previously. If the file existed previously, it returns false.A program that demonstrates this ... Read More

Get the value associated with a given key in Java HashMap

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

Use the get() method to get the value associated with a given key.Here is our HashMap and its elements −// Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));To ... Read More

Go-Back-N ARQ

karthikeya Boyini

karthikeya Boyini

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

11K+ Views

Go-Back-N Automatic Repeat reQuest (Go-Back-N ARQ), is a data link layer protocol that uses a sliding window method for reliable and sequential delivery of data frames. It is a case of sliding window protocol having to send window size of N and receiving window size of 1.Working PrincipleGo – Back ... Read More

Create a TreeMap in Java and add key-value pairs

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

A TreeMap cannot contain duplicate keys. TreeMap cannot contain the null key. However, It can have null values.Let us first see how to create a TreeMap −TreeMap m = new TreeMap();Add some elements in the form of key-value pairs −m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");The following ... Read More

Display File class constants in Java

karthikeya Boyini

karthikeya Boyini

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

90 Views

The java.io.File class has display constants File.separatorChar and File.pathSeparatorChar mainly. The File.separatorChar is ‘/’ and the File.pathSeparatorChar is ‘:’ for Unix.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       try {     ... Read More

Java Program to remove a key from a HashMap

karthikeya Boyini

karthikeya Boyini

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

499 Views

To remove a key from HashMap, use the remove() method.First, create a HashMap and add elements −// Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));Let us now remove ... Read More

Java Program to create a file and sets it to read-only

karthikeya Boyini

karthikeya Boyini

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

88 Views

A file can be set to read-only by using the method java.io.File.setReadOnly(). This method requires no parameters and it returns true if the file is set to read-only and false otherwise. The method java.io.File.canWrite() is used to check whether the file can be written to in Java and if not, ... Read More

Advertisements