Found 33676 Articles for Programming

What is a Locale class in Java?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:20

210 Views

The java.util.Locale class object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to form information for the user. The locale is a mechanism for identifying objects, not a container for the objects themselves.

How to move a file from one folder to another using Python?

Sarika Singh
Updated on 15-May-2025 18:20:01

6K+ Views

The Python shutil module provides a number of functions for high-level operations on individual files and file collections. In this article, we will go through different methods of moving a file from one folder to another using Python. Using the OS Module The Python OS module gives users the ability to create interactions with their operating systems. Using shutil.move() method Following is an example which shows how to move a file from one folder to another using shutil.move() method - # importing the modules import shutil import os # Providing the folder path origin = 'C:\Users\Lenovo\Downloads\Works' target = 'C:\Users\Lenovo\Downloads\Work ... Read More

What is the purpose of System class in Java?

Lakshmi Srinivas
Updated on 30-Jul-2019 22:30:20

2K+ Views

System class belongs to the package java.lang. It cannot be instantiated. A System class provides − standard output. error output streams. standard input and access to externally defined properties and environment variables. A utility method for quickly copying a portion of an array. a means of loading files and libraries. Following are the fields for java.lang.System class − static PrintStream err − This is the "standard" error output stream. static InputStream in − This is the "standard" input stream. static PrintStream out − This is the "standard" output stream.

How to copy certain files from one folder to another using Python?

SaiKrishna Tavva
Updated on 01-Sep-2025 14:53:40

3K+ Views

When we are working with files in Python we may need to copy only a certain type of file. Python makes this task simple and flexible by using built-in modules such as os and shutil and pathlib. Copying specific files using shutil and os modules When we want to copy only certain files such as all .txt files from one folder to another in Python then we can use the shutil and os modules. The shutil module is used to perform high-level operations on files such as file copying, moving, archiving and removing directories whereas os module is used to ... Read More

What is Callable interface in Java?

Sharon Christine
Updated on 30-Jul-2019 22:30:20

899 Views

The Callable interface is found in the package java.util.concurrent. The Callable object can return the computed result done by a thread in contrast to a runnable interface which can only run the thread. The Callable object returns a Future object which provides methods to monitor the progress of a task being executed by a thread. The future object can be used to check the status of a Callable and then retrieve the result from the Callable once the thread is done. It also provides timeout functionality.

How to copy files from one folder to another using Python?

Sarika Singh
Updated on 15-May-2025 17:52:03

45K+ Views

We can easily check the Odd or Even by using conditional statements. We can divide the number by 2, then check whether the remainder is 0 or not. If 0, then it is even. We can also perform the AND operation with the number and 1. If the answer is 0, then it is even; otherwise odd. There is no need to use conditional statements in both approaches. We will see two different methods to check the odd or even. Using Modulo Operator This approach uses the Modulo Operator ... Read More

What is Runnable interface in Java?

Revathi Satya Kondra
Updated on 17-Jan-2025 19:43:29

960 Views

An interface is like a reference type, similar to a class that enforces the rules that the class must implements(It is a keyword). An interface may have abstract methods i.e. methods without a definition and also constants or variables with fixed value. What is a Runnable interface in Java? If your class is intended to be executed as a thread, then you can achieve this by implementing a Runnable interface. This belongs to the java.lang package. The Runnable interface in Java is a functional interface that enables the compiled code of the class to run as a separate thread. The ... Read More

Can private methods of a class be accessed from outside of a class in Java?

Samual Sam
Updated on 18-Feb-2020 09:45:41

15K+ Views

You can access the private methods of a class using java reflection package.Step1 − Instantiate the Method class of the java.lang.reflect package by passing the method name of the method which is declared private.Step2 − Set the method accessible by passing value true to the setAccessible() method.Step3 − Finally, invoke the method using the invoke() method.Exampleimport java.lang.reflect.Method; public class DemoTest {    private void sampleMethod() {       System.out.println("hello");    } } public class SampleTest {    public static void main(String args[]) throws Exception {       Class c = Class.forName("DemoTest");       Object obj ... Read More

How to compare two different files line by line in Python?

Sarika Singh
Updated on 17-Aug-2022 13:56:40

11K+ Views

This tutorial looks at various Python comparison techniques for two files. We'll go over how to perform this typical work by using the available modules, reading two files, and comparing them line by line. In Python, comparing two files can be done in a variety of ways. Comparing Two Text Files Line by Line Using the open() function to read the data from two text files, we can compare the information they contain. The local directory will be searched for and potentially read by the open() function. Example We'll contrast two files containing python data in this example. We're informed ... Read More

Where and how is import statement used in Java programs?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:20

323 Views

Wan import statement in Java is used to − Import user defined classes/Interfaces Whenever you need to access a class which is not in the current package of the program you need to import that particular class using the import statement. Example In the following example we are using the Math class to find the square root of a number therefore, first of all w should import this class using the import statement. Live Demo import java.lang.Math.*; public class Sample{ public static void main(String args[]){ System.out.println(Math.sqrt(169)); ... Read More

Advertisements