input output in java

input output in java

java program using filereader and filewriter

View Answers

January 7, 2011 at 10:39 AM

Hi Friend,

Try the following code:

import java.io.*;
class FileInputStreamAndFileOutputStream
{
    public static void main(String[] args) throws Exception {
      FileInputStream in = new FileInputStream("c:/hello.txt");
      FileOutputStream out = new FileOutputStream("C:/data.txt");
      int c;
      while ((c = in.read()) != -1) {
        out.write(c);
      }
      out.close();
      System.out.println("File is copied");
    } 
    }

Thanks


January 7, 2011 at 10:43 AM

Hi Friend,

Try the following code:

import  java.io.*;
class FileReaderAndFileWriter{
      public static void main(String[] args) throws IOException {

    FileReader in = new FileReader("C:/Hello.txt");
    FileWriter out = new FileWriter("C:/new.txt");
    int c;
    while ((c = in.read()) != -1){
    out.write(c);
    }
    out.close();
    System.out.println("File is copied");
  }
}

Thanks









Related Tutorials/Questions & Answers:
input output in java
input output in java  java program using filereader and filewriter   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args) throws
Input / Output in Easiest Method in Java
Input / Output in Easiest Method in Java  How to input from keyboard... with the easiest method in Java?   Hi Friend, Try the following code: import...)throws Exception{ Scanner input=new Scanner(System.in
Advertisements
Input and Output problems - Java Beginners
Input and Output problems  1) what is Difference between... to a particular platform. Thus, this class reads characters from a byte input stream.... This link will help you. http://www.roseindia.net/java/beginners
input output
Input And Output       Introduction The Java I/O means Java Input/Output and is a part... for any input/output operations. Classes Defined in the program: OnlyExt
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
input output
input output  java program using fileinputstream and fileoutputstream   Hi Friend, Try the following code: import java.io.*; class FileInputStreamAndFileOutputStream { public static void main(String[] args
Java Input/Output Examples
Java Input/Output Examples In this tutorial you will learn about how the Inputs and outputs are managed in java. To understand the Java Input & Output... and interfaces to handle the system input & output through data streams
Data input & output Stream
Data input & output Stream  Explain Data Input Stream and Data Output... stream lets an application read primitive Java data types from an underlying input... write primitive Java data types to an output stream in a portable way
Input and Output package
Input and Output package  Hi guys, My professor used input and output... she used in.readint() out.writeln() commands to read input and print output. she created two new objects directly to use this statements. /* input and output
Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
to the current location. ADS_TO_REPLACE_3 Output of the Program C:\nisha>javac CreateFile1.java C:\nisha>java CreateFile1... in the output. C:\nisha>javac CreateFile1.java C:\nisha>
counting the values in input file and and writing the output to a file
counting the values in input file and and writing the output to a file ... it should write the output to a file. Input file has 20 rows and 4 columns. If we...-code/16483-counting-values-input-file-writing-output-file.html this code
Java Command Line Input
Java Command Line Input  How to get input from command line in java... this code you will find the output as Please Input A Number 2 data is- 2... System.out.println("Please Input A Number"); BufferedReader br
Input - Output String Functions
Input - Output String Functions      ... a string data and input them directly into your database. Some special characters...;;ADS_TO_REPLACE_3 echo stripslashes($str); ?> Output:ADS_TO_REPLACE_4
different type input in java
type of input method. thank   Java Read through DataInputStream: import...); } }   Java read input through Scanner: import java.util.*; class...); } }   Java read input through BufferedReader import java.io.*; public class
output java - Java Beginners
; } a. what is the output of the ff. java statement:? i. System.out.println (secret...output java  public static int secret(int one) { int i; int...?  Hello Are you beginner? Ok, The first Output is 125
java input problem - Java Beginners
java input problem  I am facing a Java input problem
input
input  a java program that will exchange the last names of two students that were input by a user
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full name in name variable...how i can store full name plsss reply   use
input - Java Beginners
me soon.  Hi Friend, There are lot of ways to input data.You can use... to input the data from the command prompt. Try the following code to input name...:"); Scanner input=new Scanner(System.in); String name=input.nextLine
output
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
File Handling Classes in Java
In this section, you will get to know about file handling classes in java to handle the file input output operations
java user input - Java Beginners
java user input  how to input from keyboard? please give a example.  Hi Friend, There are lot of ways to input data from keyboard.You...:****** try{ System.out.print("Enter String:"); BufferedReader input = new
Process Flows Output - Java Beginners
Process Flows Output  Hi, I have been asked to get a particular structure as the output. the assignment is as follows Any process flow has..... there might be a split activity sumwhere in the process, that splits the process flow
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from the command prompt. We are providing you a java application
Output of this one - Java Interview Questions
Output of this one   public class Test { int i=-277; { try{ if(Byte i<<1) { System.out.println("Executed"); } else... errors. The following code displays "Executed" as an output. public class
user input in java - Java Beginners
user input in java   i am trying to write a code to compute the average of 5 numbers but i dont know what to do for the program to accept user input  Hi import java.util.*; public class AverageExample { public
Redirecting the console output into a file in Java
Redirecting the console output into a file in Java  Hi, i coded a program that read specific lines from a text file. It's working well. Now i want to redirect the output of the console to a text file. i used your tutorial
Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature of various O/S, are read through standard input in Java. Standard streams are read
Command Line Standard Output In Java
Command Line Standard Output In Java In this section we will discuss about the Command Line Java IO Standard Output. Standard streams, feature of various O/S, are written through standard output in Java. Standard streams can
Validation on input xml in java program - XML
Validation on input xml in java program  Hi.. i am accepting xml data as input which I have to use in my program. i have to validate this input xml against some schema using xml beans and NOT by using sax or dom parser. I am
JSP to output Java String Array - JSP-Servlet
JSP to output Java String Array  I am just a little confused about the output that I would get from printing a 2D String array loaded with database fields. For example lets say we have the following array: String [ ][ ] array
How to capture output from console into textarea in java?
How to capture output from console into textarea in java?  Hi, I would like to know how can we display the result of a program in java into a textarea instead of displaying it on console. Thanks
How to get the unicode of japanese character input in java
How to get the unicode of japanese character input in java  Good Evening sir/madam; I am trying to create an application in java which needs to show the japanese character on frame and need to get the japanese string from
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... there is different output trying to execute same java code
input box
input box  give me the code of input box in core java
input box
input box  give me the code of input box in core java
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
different output trying to execute same java code
different output trying to execute same java code  i am using net beans 7 ide and java 6 to develop my java projects. i used the following coding... " portList : false" Why there is different output trying to execute same java
Read user input in Java using Scanner
Example of of reading user input in Java using Scanner In this section we are explaining the use of Scanner class in Java which can be used to read user... back on the console. There are various ways to read user input in Java
input ang message box - Java Beginners
input ang message box  can you help me to calculates for the sum, difference, product and quotient of the two inputted values using Input Dialog...("Input First Number"); int num1=Integer.parseInt(input1); String input2
plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18
Java Redirect output to file
Java Redirect output to file This section illustrates you how to redirect the output to the file. It may be comfortable to a programmer if they are able... to the file. In the given example, we have set the output stream of System
jsf form output - Java Server Faces Questions
button it goes to hello.jsp page and gives the output with all the details whatever
jsf form output - Java Server Faces Questions
the output with all the details whatever i provide. It is urgent for me please give
blank space in input field - Java Beginners
blank space in input field  I retrieved the fields from my mysql table...If the field contains null value i want to display a blank space in input field(text box)..but i am displaying null how to overcome this.. u r help
Java I/0 Examples
output error
]; for (k=0;k } } if i enter "my name" as the input the output...output error  this is my program import java.io.*; public class separate { public static void main(String[] args)throws IOException
Maven dependency for com.bytebreakstudios - input version 1.6.0 is released. Learn to use input version 1.6.0 in Maven based Java projects
this version ( com.bytebreakstudios - input version 1.6.0 ) in their Java...Maven dependency for  com.bytebreakstudios  - Version 1.6.0 of input released The developers of   com.bytebreakstudios - input project
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6

Ads