Home Answers Viewqa Java-Beginners Difference between Java IO Class

 
 


Pabitra Kr Debnath
Difference between Java IO Class
1 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

View Answers

October 24, 2008 at 6:45 PM


Hifriend,


1. The FileOutputStream class is a subclass of OutputStream.
2. You can construct a FileOutputStream object by passing a string containing a path name or a File object.
3. You can also specify whether you want to append the output to an existing file.



public FileOutputStream (String path)
public FileOutputStream (String path, boolean append)
public FileOutputStream (File file)
public FileOutputStream (File file, boolean append)

--------------

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamClassDemo {
public static void main(String[] args) {
File originFile = new File("/home/vinod/amarexamples/file1.txt");
File destinationFile = new File("/home/vinod/amarexamples/file2.txt");
if (!originFile.exists() || destinationFile.exists()) {
return;
}
try {
byte[] readData = new byte[1024];
FileInputStream fis = new FileInputStream(originFile);
FileOutputStream fos = new FileOutputStream(destinationFile);
int i = fis.read(readData);

while (i != -1) {
fos.write(readData, 0, i);
i = fis.read(readData);
}
fis.close();
fos.close();
} catch (IOException e) {
System.out.println(e);
}
}
}

-------------------------------------------

Visit for more information.

http://www.roseindia.net/java/

Thanks.










Related Pages:
Difference between Java IO Class - Java Beginners
Difference between Java IO Class  What is the difference in function between Two set of Stream class as mention below- 1)FileInputStream...   Hifriend, 1. The FileOutputStream class is a subclass
difference between enum and final class?
difference between enum and final class?  what is the difference between enum and final class in java?   The java.lang.Enum is an abstract class, it is the common base class of all Java language enumeration types
io
io  write a program in java to accept a filename from user and print its content on the monitor   Hello Friend, Try the following code: import java.io.*; import java.util.*; class DisplayContentOfFile { public
difference
difference  difference between Method Overloading and method Overriding   Difference between Method Overloading and Method Overriding... in different classes. one in the super class can be made virtual and other can override
difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between
Difference between C++ and Java - Java Interview Questions
Difference between C++ and Java  Basic difference between C... was derived from C++ but still there is big difference between these two... am going to give you few differences between these two...1. Java does not support
difference
difference    what is the difference between the JDBC-ODBC bridge, the Native-API-Partly-Java driver, and the JDBC-Net-All-Java Driver is the placement of the database access libraries   Please visit the following link
difference
difference  difference between thread and process in java   Difference between Process and Thread: 1)Process is a program under execution whereas Thread is a part of program. 2)Process are heavy weight programs which
Hi .Difference between two Dates - Java Beginners
Hi .Difference between two Dates  Hi Friend.... Thanks for ur Very good response.. Can u plz guide me the following Program.... difference between two dates.. I need to display the number of days by Each Month
What are the difference between abstract class and interface?
What are the difference between abstract class and interface?  What are the difference between abstract class and interface
Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java
Difference between the local and class variable.
class. Below two program are shown which help you to understand the difference between the class and local variable. Showing Local Variable...Description: The class variable are declared in the class but not within
Java: Kilometer to Miles - IO Class
Java NotesKilometer to Miles - IO Class 1 2 3 4 5 6... to their own class. import javax.swing.*; import java.text.*; public class.... double miles; // Number of miles. IOHandler io
io
io  create a meanu based text editor in java having features of creating file,viewing file,deleting file,renaming file,copying file and cutting file
difference between lock and synchronization
difference between lock and synchronization  Hi, I am new in java please anyone tell me difference between lock and synchronization in java. its urgent. Thank in advance   Please visit the following link: Lock
IO concept
IO concept  Write a java program that moves the contents of the one... the following code: import java.io.*; class MoveFile{ public static void main(String...!"); } } For more information, visit the following link: Java Move File Thanks
difference between hashcode,reference in java
difference between hashcode,reference in java  difference between hashcode,reference in java
Difference between == and equals method in java
Description: For comparing equality of string ,We Use equals() Method. There are two ways of comparison in java. One is "==" operator and another... class. This method compares content of the string object. . Code
What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Read Here Thanks
difference between applet and swings
difference between applet and swings  what are the major difference between swing and applets   Hello Friend, Differences: 1) AWT stands for Abstract windows toolkit whereas le Swing is also called as JFC?s (Java
what is the difference between jdk 1.4 and 1.5 and 1.6
what is the difference between jdk 1.4 and 1.5 and 1.6  what is the difference between jdk 1.4 and 1.5 and 1.6   Java 1.4 Features..., JSSE, JAAS) - Java web start Java 5.0 Features - Generics: provides compile
Difference between error and exception ????????
Difference between error and exception ?  Can we handle a error in java if yes than give an code of an example? Difference between error and exception handling.......   Exceptions are things you can create/throw
Difference between extends thread class vs implements runnable interface - Java Interview Questions
Difference between extends thread class vs implements runnable interface  Hi Friends, can you give difference between extending thread class and implementing runnable interface.  Hi Friend, Difference: 1)If you
What is the difference between a constructor and a method?
What is the difference between a constructor and a method?  Hi, What is the difference between a constructor and a method?   Hi, I have found a good link of Java program related to difference between constructor
difference between servletconfig and servletcontext in java
difference between servletconfig and servletcontext in java  difference between servletconfig and servletcontext in java   ServletContext ServletContext is implemented by the servlet container for all servlet
difference between wite and writeto in java
difference between wite and writeto in java  I am using the stream... the writeTo() method. I want to know difference between the write() and writeTo() method in java.   The writeTo() method writes the complete contents
to calculate the difference between two dates in java - Java Beginners
to calculate the difference between two dates in java  to write a function which calculates the difference between 2 different dates 1.The function... class DeltaDays { public static void main(String[] args
File IO
are planning to learn file management using Java IO package.This class is available... The Java IO package is used to perform various input/output processing activities.In this section we are giving overview of java IOJava io classes
What is difference between the java and javascript?
What is difference between the java and javascript?  What is the difference beteen the java and javascript?   Hello Friend, Difference: 1) Java is a Object Oriented programming language developed by Sun Microsystems
difference between servletconfig and servletcontext in java
difference between servletconfig and servletcontext in java  ServletConfig is implemented by the servlet container to initialize a single servlet using init(). ServletContext is implemented by the servlet container for all
difference between the obj and reference - Java Beginners
difference between the obj and reference  what is the difference between object and reference ? is there any difference
What is the difference between a JDK and a JVM?
What is the difference between a JDK and a JVM?  Hi, What is the difference between a JDK and a JVM? Thanks,   Hi, JDK is stand... to compile your source files using a JVM. For more difference between JDK and JVM
Difference between Encapsulation and Abstraction in Java
In this section we will discuss about the difference between Encapsulation and Abstraction in Java. Encapsulation is a process of hiding all the data.... Abstraction in Java is represented by Interface, Abstract class, Abstract methods
What’s the difference between accessing a class method via -> and via ::?
What?s the difference between accessing a class method via -> and via ::?  What?s the difference between accessing a class method via -> and via
What is the difference between a static and a non-static inner class?
What is the difference between a static and a non-static inner class?   Hi, What is the difference between a static and a non-static inner class? Thanks
java-io - Java Beginners
java-io  Hi Deepak; down core java io using class in myn... ********************************** import java.io.*; import java.util.*; class Arr1 { int r,c..."); } System.out.println(); } } } public class Arr { public static void main
Difference between object and instance? - Java Beginners
Difference between object and instance?  What is the difference between object and instance in java
What is difference between Path and Classpath?
What is difference between Path and Classpath?   hi What is difference between Path and Classpath? thanks   Hi, The Path &... and classpath is used to specify the location .class files. Fore more details on Path
difference between marker and tag interface - Java Interview Questions
difference between marker and tag interface  what is the difference between marker interface and tag interface?  Hi friend, nterface...); } Marker Interface In java language programming, interfaces with no methods
what is difference between objectan primitive? - Java Beginners
what is difference between objectan primitive?  whatis difference between object and primitive
Difference between class,name,id attributes in each JSP tag
Difference between class,name,id attributes in each JSP tag  Can i know the difference between class,name,id attributes in each JSP tags.................. These 3 are only used for reference ..... And what are the differernces
Difference between getCurrentSession() and openSession() in Hibernate ?
Difference between getCurrentSession() and openSession() in Hibernate ?  What is difference between getCurrentSession() and openSession... for your JEE container set hibernate.transaction.factory_class
difference between java5 and java6 - Java Beginners
difference between java5 and java6  Hi, What is difference between java5 and java6 Please let me know quickly
io - Java Beginners
, import java.io.*; import java.awt.*; public class DataTest { public.... http://www.roseindia.net/java/ Thanks Amardeep
difference - Java Interview Questions
difference  what is the difference between instance and object? ... at a particular time whereas object refers to the memory address of the class. For ex... you are creating an instance of class and some memory is occupied by object
Give difference between LinkedList and ArrayList - Java Beginners
Give difference between LinkedList and ArrayList  Hi, What is the use of LinkedList and ArrayList? How you can difference between LinkedList.... For more information, visit the following links: http://www.roseindia.net/java
Java Swing Date Difference
Java Swing Date Difference In this tutorial, you will learn how to find the difference between two dates. Here is an example that accepts two dates from... in the format dd-MM-yyyy using the SimpleDateFormat class. We have created
Difference between GenericServlet and HttpServlet
In this section we will discuss about the difference between GenericServlet and HttpServlet. GenericServlet is an abstract class that extends java.lang.Object while HttpServlet is an abstract class that extends GenericServlet
Class
. Constructor is the method which name is same to the class. But there are many difference... Class, Object and Methods       Class : Whatever we can see in this world all the things
Difference between C++ and Java
. Following are the difference between C++ and Java: Although both are and was derived from but still there is big difference between these two languages. Java does not support operator overloading A class definition

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.