Character Stream I/O in Java

In a java programming, like a Byte stream Character stream is also used for input-output for 16 bit. But Byte streams are used to perform input and output of 8-bit. Most common Character streams classes are, FileReader and FileWriter.  FileReader- FileReader uses for reads two bytes at a time.  FileWriter– FileWriter uses for writes two bytes at a … Read more

Concatenate & Buffer File in Java

Here we will concatenating and store buffering files in java using BufferedInputClass and BufferedOutputClass. Concatenate: It is possible to concatenate two or more files and save in a different file. In java, by using SequenceInputStream class we can concatenate two or more files. Buffer Files: In java, we can create a buffer to store temporary … Read more

Displaying file properties

Displaying file properties can be easily done in java package io; import java.io.File; import java.io.IOException; public class FileOrDir { public static void main(String[] args) { File f = new File(“D:\\first.txt”); File f1 = new File(“D:\\second.txt”); if (f.exists() == false) { System.out.println(“File or Directory does not exists”); } if (f.isDirectory()) { System.out.println(“This is a directory”); } … Read more

Reading a text file in Java

For reading a file we have to create a FileReader object. Then we create BufferedReader object of FileReader. If file not found FileReader constructor throws FileNotFoundException. If br.readLine() is not able to read source file it throws IOException.

PHP Working with Directories

Handle a directory there are several functions in PHP language. i. mkdir() ii. opendir() iii. readdir() iv. scandir() v. rmdir() vi. closedir() i. Create Directory Want to create a new folder using PHP then use mkdir(). Only one argument is required the folder name or folder location where want to create the folder. Example

Read more

Byte Streams in Java

In java programming, to perform input and output of 8-bit, Byte stream is used. Most common byte streams classes are, FileInputStream and FileOutputStream. FileInputStream : FileInputStream is used for reads one byte at a time . FileOutputStream : FileOutputStream is used for writes one byte at a time Writing Bytes Example: Write a program, to write a bytes to … Read more

DataInputStream and DataOutputStream for primitive data

In java, a basic input-output stream provides a method for reading & writing bytes or characters in a file. If we want to read-write primitive data types (such as int, float, etc.) then we can use filter classes to filter data in the original stream. DataInputStream & DataOutputStream are two filter classes used for creating … Read more

Displaying directory contents in Java

For listing a directory content in java we use File class and use isDirectory() method to check whether it is directory or not. if directory then we use listFiles().

Reading a file using FileInputStream

Reading a file using FileInputStream To read a file using FileInputStream in Java, follow these steps: Import the necessary packages: import java.io.FileInputStream; import java.io.IOException; 2. Create a FileInputStream object for the file you want to read: FileInputStream fis = new FileInputStream(“filename.txt”); 3. Create a buffer array to store the data you read from the file: … Read more

PHP File Handing

File handling is need for any web application so FILE HANDLING is an important part of PHP language. Some task to be done file needs to be processed. PHP have many function handling any kind of normal files. (Liketxt, docx, csv, jpg etc) Handle a file need to know below topics i. File create ii. … Read more