Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Difference between Java IO Class

Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
Difference between abstract class and an interface
Difference between abstract class and an interface The difference between... between abstract class and interface in java. Abstract class is a class... in java. Third difference is that abstract class begin with the abstract
difference between hashcode,reference in java
difference between hashcode,reference in java  difference between hashcode,reference in java
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 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
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
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
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 documentation comment and multiline comment in java?
Difference between documentation comment and multiline comment in java?  Difference between documentation comment and multiline comment in java
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
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
Difference between object and instance? - Java Beginners
Difference between object and instance?  What is the difference between object and instance in java
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 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 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 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 difference between objectan primitive? - Java Beginners
what is difference between objectan primitive?  whatis difference between object and primitive
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
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
difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between
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
Difference between API and Assembly - Java Beginners
Difference between API and Assembly  Can anybody tell me what is the diffrenece between API's and assemblies?  Hi friend, Points to be remember : API *) API Stands for "Application Program Interface
In Java, what's the difference between public, default, protected, and private?
In Java, what's the difference between public, default, protected, and private?  In Java, what's the difference between public, default, protected, and private
pls tell me the difference between the run() and start() in threads in java....
pls tell me the difference between the run() and start() in threads in java....  difference between the run() and start() in threads in java
what is the difference between access specifiers and access modifiers in java?
what is the difference between access specifiers and access modifiers in java?  what is the difference between access specifiers and access modifiers 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
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
java io - Java Beginners
Java IO Streams  What is the Java IO Stream
Difference between struts and JSF
Difference between struts and JSF  What is the difference between struts and JSF
difference between ForwardAction and IncludeAction
difference between ForwardAction and IncludeAction  What is the difference between ForwardAction and IncludeAction
difference between SessionState and ViewState
difference between SessionState and ViewState  What is the difference between SessionState and ViewState
Difference between DispatchAction and LookupDispatchAction
Difference between DispatchAction and LookupDispatchAction  What is the Difference between DispatchAction and LookupDispatchAction
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
java io
java io  by using java coding how to invoke a particular directory
Java IO
Java IO  What an I/O filter
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
java IO
java IO  Write a Java program to accept a file name as command line argument. Append the string "File Modified by Programme" to the end of the same file and print the contents of the modified File
java io
java io  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
What is the difference between the >> and >>> operators?
What is the difference between the >> and >>> operators?   hi, What is the difference between the >> and >>> operators? Thanks
Difference between 3d and 4d
Difference between 3d and 4d  what is the difference between 3d and 4d
difference between varchar & varchar2?
difference between varchar & varchar2?  What is the difference between varchar & varchar2
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
Difference in size of .java & its respective .class file
Difference in size of .java & its respective .class file  Hai, I had created & compiled a java class named sample.java. The size of sample.java is 340KB. Whereas the size of its respective class file sample.class is 137KB
io packages - Java Beginners
io packages  How can I add two integers in java using io pacages
Difference between Mysql and SQL
Difference between Mysql and SQL  hello, What is the difference between Mysql and SQL??   hii, SQL is structural quary language but mysql is database package
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
Advertisements
 

 

 

DMCA.com