Found 33676 Articles for Programming

How to delete a Python directory effectively?

SaiKrishna Tavva
Updated on 01-Sep-2025 14:59:04

907 Views

When we are working with Python files or directories, we may often need to delete them to perform tasks such as cleaning up temporary files. Deleting directories isn't an easy task when compared with deleting files. In this article, we will explore all the different methods to delete a Python directory. Using shutil.rmtree() for Recursive Deletion The shutil module in Python has the rmtree()function, which is used to recursively delete a directory and all its contents. This function takes the directory path as the input parameter. Example Following is the example which uses the function shutil.rmtree() to delete a directory ... Read More

What is the difference between simple name, canonical name and class name in a Java class?

vanithasree
Updated on 30-Jul-2019 22:30:20

3K+ Views

Canonical name of a Java class is the name of the class along with the package. For example, the canonical name of the class File is java.io.File. You can also get the canonical name of a particular class using Java method. The class named Class provides a method getCanonicalName(), this method returns canonical name of the current class. Example Live Demo import java.lang.*; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = c.getClass(); ... Read More

How to access the members of a class from another class in Java?

radhakrishna
Updated on 30-Jul-2019 22:30:20

13K+ Views

To access the members of a class from other class. First of all, import the class. Create an object of that class. Using this object access, the members of that class. Suppose there is a class in a package called myPackage with a method named display() package myPackage; public class Sample { public void display() { System.out.println("Hello"); } } You can access it as. import myPackage; public class MyClass { public static void main(String args[]) { Sample s = new Sample(); s.done(); } } Output hello

Why do Java array declarations use curly brackets?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:20

663 Views

Curly brackets usually denote sets and ensembles while parenthesis usually in most Algol-based programming languages curly braces are used to declare arrays.

How to declare a class in Java?

mkotla
Updated on 30-Jul-2019 22:30:20

14K+ Views

Following is the syntax to declare a class. class className { //Body of the class } You can declare a class by writing the name of the next to the class keyword, followed by the flower braces. Within these, you need to define the body (contents) of the class i.e. fields and methods.To make the class accessible to all (classes) you need to make it public. public class MyClass { //contents of the class (fields and methods) }

How to convert a byte array to a hex string in Java?

Abhinaya
Updated on 30-Jul-2019 22:30:20

588 Views

The printHexBinary() method of the DatatypeConverter class accepts a byte array and returns a hex string.Exampleimport javax.xml.bind.DatatypeConverter; public class ByteToHexString { public static void main(String args[]) { String sam = "Hello how are you how do you do"; byte[] byteArray = sam.getBytes(); String hex = DatatypeConverter.printHexBinary(byteArray); System.out.println(hex); } }Output48656C6C6F20686F772061726520796F7520686F7720646F20796F7520646F

What are Java classes?

Giri Raju
Updated on 30-Jul-2019 22:30:20

548 Views

A class in Java is a user-defined datatype, a blueprint, a classification, that describes the behavior/state that the object of its type support. Example public class Dog { String breed; int age; String color; void barking() { } void hungry() { } void sleeping() { } } A class can contain any of the following variable types. Local variables − Variables defined inside methods, constructors or blocks are called local ... Read More

How to convert BLOB to Byte Array in java?

Ramu Prasad
Updated on 30-Jul-2019 22:30:20

8K+ Views

You can contents of a blob into a byte array using the getBytes() method.Exampleimport java.awt.Image; import java.awt.image.BufferedImage; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Arrays; public class BlobToByteArray { public static void main(String[] args) throws Exception { Image image = new BufferedImage(300, 400, BufferedImage.TYPE_INT_RGB); String JDBC_DRIVER = "com.mysql.jdbc.Driver"; String DB_URL = "jdbc:mysql://localhost/mydb"; String USER = "root"; String PASS = "password"; ... Read More

How to Map multi-dimensional arrays to a single array in java?

V Jyothi
Updated on 19-Feb-2020 12:15:46

2K+ Views

A two-dimensional array is nothing but an array of one dimensional arrays. Therefore to map a two dimensional array into one dimensional arrays.Create arrays equal to the length of the 2d array and, using for loop store the contents of the 2d array row by row in the arrays created above.Examplepublic class Mapping_2DTo1D {    public static void main(String args[]) {       int [][] array2D = {{7, 9, 8, 5}, {4, 5, 1, 8}, {9, 3, 2, 7}, {8, 1, 0, 9}};       int [] myArray1 = new int[array2D[0].length];       int [] myArray2 = ... Read More

How to scan through a directory recursively in Python?

Alekhya Nagulavancha
Updated on 15-May-2025 18:30:14

14K+ Views

A directory is simply defined as a collection of subdirectories and single files or either one of them. A directory hierarchy is constructed by organizing all the files and subdirectories within a main directory and this is also known as root directory. These subdirectories are separated using a / operator in a directory hierarchy. In python, we have different methods to scan through a directory recursively. In this article we are going to see about each method. Using os.walk() method Using glob.glob() method Using os.listdir() method ... Read More

Advertisements