Copy Characters from One File to Another in Java

Maruthi Krishna
Updated on 02-Aug-2019 11:24:50

3K+ Views

To copy the contents of one file to other character by characterExampleimport java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyFiles {    public static void main(String[] args) throws IOException {       //Creating a File object to hold the source file       File source = new File("D:\ExampleDirectory\SampleFile.txt");       //Creating a File object to hold the destination file       File destination = new File("D:\ExampleDirectory\outputFile.txt");       //Creating an FileInputStream object       FileInputStream inputStream = new FileInputStream(source);       //Creating an FileOutputStream object       FileOutputStream outputStream = ... Read More

Get File URI Reference in Java

Maruthi Krishna
Updated on 02-Aug-2019 11:21:24

5K+ Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.In general, an URI (Uniform Resource Identifier) represents a resource. The URI class of Java represents this format You can get the URI format of a file by invoking the toURI() method.ExampleFollowing Java example, prints the URI format of the file named samplefile.txtimport java.io.File; import java.io.IOException; import java.net.URI; public class GetURI {    public static void main(String args[]) throws IOException {       //Instantiating the File class       String ... Read More

Create and Store Property File Dynamically in Java

Maruthi Krishna
Updated on 02-Aug-2019 11:18:19

3K+ Views

The .propertiesis an extension in java which is used to store configurable application. It is represented by the Properties class in Java, you can store a properties file and read from it using the methods of this class. This class inherits the HashTable class.Creating a .properties fileTo create a properties file −Instantiate the Properties class.Populate the created Properties object using the put() method.Instantiate the FileOutputStream class by passing the path to store the file, as a parameter.ExampleThe Following Java program creates a properties file in the path D:/ExampleDirectory/import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; public class CreatingPropertiesFile {    public static ... Read More

Compress and Uncompress Data of a File in Java

Maruthi Krishna
Updated on 02-Aug-2019 11:11:37

1K+ Views

Java provides a two classes namely, DeflaterOutputStream and InflaterInputStream for compressing and uncompressing data.Compressing a Single fileTo compress a single file −Create a FileInputStream object, by passing the path of the file to be compressed in String format, as a parameter to its constructor.Create a FileOutputStream object, by passing the path of the output file, in String format, as a parameter to its constructor.Create a DeflaterOutputStream object, by passing the above created FileOutputStream object, as a parameter to its constructor.Then, read the contents of the input file and write using the write() method of the DeflaterOutputStream class.Exampleimport java.io.FileOutputStream; import java.io.IOException; ... Read More

Filter Files by Extensions and Show Names in Java

Maruthi Krishna
Updated on 02-Aug-2019 11:06:45

3K+ Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.To get the list of all the existing files in a directory this class provides five different methods to get the details of all files in a particular folder −String[] list()File[] listFiles()String[] list(FilenameFilter filter)File[] listFiles(FilenameFilter filter)File[] listFiles(FileFilter filter)Among these, the String[] list(FilenameFilter filter) method returns a String array containing the names of all the files and directories in the path represented by the current (File) object. But the retuned array contains the filenames ... Read More

Asymptotic Complexity

Arnab Chakraborty
Updated on 02-Aug-2019 10:42:03

5K+ Views

Asymptotic AnalysisUsing asymptotic analysis, we can get an idea about the performance of the algorithm based on the input size. We should not calculate the exact running time, but we should find the relation between the running time and the input size. We should follow the running time when the size of input is increased.For the space complexity, our goal is to get the relation or function that how much space in the main memory is occupied to complete the algorithm.Asymptotic BehaviorFor a function f(n) the asymptotic behavior is the growth of f(n) as n gets large. Small input values ... Read More

Integrate Emojis Keyboard in an Android App

Azhar
Updated on 02-Aug-2019 09:27:03

983 Views

This example demonstrates how do I integrate emogis keyboard in android appStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml                         Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; import hani.momanii.supernova_emoji_library.Actions.EmojIconActions; import hani.momanii.supernova_emoji_library.Helper.EmojiconEditText; import hani.momanii.supernova_emoji_library.Helper.EmojiconTextView; public class MainActivity extends AppCompatActivity {    CheckBox mCheckBox;    EmojiconEditText emojiconEditText, emojiconEditText2;   ... Read More

Change Font Color of TextView in Android

Azhar
Updated on 02-Aug-2019 09:10:16

5K+ Views

This example demonstrates how do I change font color of TextView in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml         Step 3 − Add the following code to src/MainActivity.javaimport android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TextView textView1 = findViewById(R.id.textView1);       textView1.setTextColor(Color.BLUE); ... Read More

Change Font Size of TextView in Android

Azhar
Updated on 02-Aug-2019 09:05:12

16K+ Views

This example demonstrates how do I change the font size of TextView in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml             Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to androidManifest.xml ... Read More

Change Font Family of TextView in Android

Azhar
Updated on 02-Aug-2019 08:55:34

2K+ Views

This example demonstrates how do I change the font family of textView in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.        

Advertisements