473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

FileInputStream and FileOutputStream

import java.io.*;
class output
{
public static void main(String args[])throws Exception
{
try
{
FileInputStream fis=new FileInputStream("D:/R R/New Folder2/unit3/b.txt");
FileOutputStream fos=new FileOutputStream("D:/R R/New Folder2/unit3/a.txt");
int d;
while((d=fis.read())!=-1)
{
fos.write(d);
}
fis.close();
FileInputStream fis1=new FileInputStream("D:/R R/New Folder2/unit3/b.txt");
while((d=fis1.read())!=-1)
{
System.out.print((char)d);
}
fis1.close();
fos.close();
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
}
}
hey any one can explain me this code
Feb 4 '12 #1
2 3578
this program is used to write in a file but i dont know why file's name is different for output stream and input stream it should be same it is a.txt fot output stream and b.txt for input
is this program working fine ?
Feb 5 '12 #2
program does not work fine . Nothing display's on cmd.
also i done using same file name for input stream and output stream
Feb 8 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jacqueline Snook | last post by:
I am trying to reference a file on an apple mac from Java. In order to find what the URL is supposed to be, I opened it in the Safari web browser. The directory as returned was...
8
by: Rune Johansen | last post by:
Hi, I'm sorry if these questions are trivial, but I've searched the net and haven't had any luck finding the information I need. I need to perform some regular expression search and replace on...
6
by: Patrick | last post by:
Hello all! I am porting an application from C++ to Java and have run into a problem using the DataInputStream reader object. The file I am trying to read in is anywhere from 20 to 60 MB and has a...
1
by: Abhijit Gadekar | last post by:
Hello, I am getting a problem with objectinputstream and fileinputstream. Whenever I try to close a ObjectInputStream object it gives an Exception. And if I try to delete the associated file on...
15
by: atbusbook | last post by:
lets say you want a generic numerical algorithom like sum Ruby def sum lst lst.inject(0){|total,current| total*current} end Java // i dont know if there is a numeric super class for numbers
3
by: pankhudi | last post by:
I have written the code(in short) as below on the server side and client side import sun.audio.*; import java.io.*; import java.net.*; class Server2 {
4
needhelp123
by: needhelp123 | last post by:
what is the difference between following data and when we use each one.. FileInputStream FileOutputStream DataInputStream DataOutputStream BufferedInputStream BufferedoutputStream
6
Nepomuk
by: Nepomuk | last post by:
Hi! I'm trying to transfer files and to do so must, of course, read them. Now, my reference File has a size of 4.240.821 Bytes and I need something between 9 and 14 seconds to simply read it and...
6
by: Tukeind | last post by:
Hello, I've opened a file (code below) containing file names onto a FileInputStream, and attempting to open each file and place its contents onto a FileOutputStream (or buffer) and need help getting...
2
by: rubyhuang | last post by:
when using eclipse, if want to read a file(eg. using bufferedReader to read), then where to put the .txt file, no matter what place i put the .txt file to, it always said at...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.