Mehmet Tahir KAVAK
Read Write
1 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners

Hi; How can I read certain line of say 10 text files and write to one text file

View Answers

February 5, 2011 at 11:10 AM


Java Read Multiple Files and store the data into another text file

The given code reads all the text files of the directory and stored the data into another text file.

import java.io.*;
import java.util.jar.*;
class OnlyExt implements FilenameFilter{
  String ext;
  public OnlyExt(String ext){
  this.ext="." + ext;
  }
  public boolean accept(File dir,String name){
  return name.endsWith(ext);
  }
}
public class ReadMultipleFiles{
public static void main(String[]args) throws Exception{
BufferedWriter bw=new BufferedWriter(new FileWriter(new File("C:/output.txt")));
FilenameFilter ff = new OnlyExt("txt");
File f=new File("C:/");
File[] files = f.listFiles(ff);
for(int i=0;i<files.length;i++){
FileReader fr = new FileReader(files[i].getPath());
            BufferedReader reader = new BufferedReader(fr);
            String st = "";
            while ((st = reader.readLine()) != null) {
            bw.write(st);
            bw.newLine();
            }
}
bw.close();
 }
}









Related Pages:
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory
Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks
tow method to read and write .
tow method to read and write .  i have two method , frist named "readString" which has no input ,and output b type string ,. second method named "writeString" which accept b as imput and return nothing .........please i want
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
how to write and read text for javaME
how to write and read text for javaME  Hi. I have tried ur read/write coding but why i didnt get the o/p just like urs. do i have to add anything from the library? i want to type multiple line on text file then, read it from
Java file read write operation
Java file read write operation  how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass
write a progam for bubble sort using file read nd write?
write a progam for bubble sort using file read nd write?  hi, please give the code
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
how to read and write xml files in javascript
how to read and write xml files in javascript  hi m very new to javascript and xml,, now i want to read and write xml files in javascript,, please give me a sample code to do
J2ME RMS Read Write
J2ME RMS Read Write       This Application specially tries to explain how to read and write the data using RecordStore class. In the RecordStore class the following methods
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?  write a program in java to read a text file and write the output to an excel file using filereader and filewriter
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Write a C language program to read two matrices and multiply them?
Write a C language program to read two matrices and multiply them?  Write a C language program to read two matrices and multiply them?   Here is an example of multiplying two matrices using C language. #include <
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
Ajax Write
Ajax Write       ajaxWrite is a web-based word processor that can read and write Microsoft Word and other standard document formats Read full Description
Write String in Word document
Write String in Word document  How to read and write strings in word document
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data... column value that keeps on changing for every file.i have read the data from all the files and write them into a single file..the target file should have the 1st
read string - using loops in Java
read string - using loops in Java  Write a program to read a string composed of an unknown number of words, then count the number of words in the string, and Display the longest and shortest words, with first letter Uppercase
Write to a file
Write to a file       As we have read about  the BufferedOutputStream class that store the data in an internal buffer and lets you write
how to write in xml? - XML
how to write in xml?  can anybody give the code how to write in xml file. i wan to write inside the tag, so what i have to do? Thanks...  ...) tFormer.setOutputProperty(OutputKeys.METHOD, "text"); // Write the document to a file
Read PDF file
Read PDF file Java provides itext api to perform read and write operations with pdf file. Here we are going to read a pdf file. For this, we have used PDFReader class. The data is first converted into bytes and then with the use
write program - Java Beginners
write program  write a java program that will read the values of matrix A and B give its multiplication in matrix C  Hi friend, Code for Matrix Multiplication : class MatrixMultiplication{ public static void
write the result into excelsheet
write the result into excelsheet  package reader; import... InterruptedException, IOException { String fileName="E:\\excellogin.xls";; //Read...); //Print the data read printToConsole(dataHolder
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
Read page from Web server
) The we have used the BufferReader class to read the data in buffer c) Finally... }//end class ReadURL Another way to read from a server It's possible... and traceroute) that you can not write in Java. Copyleft 2003 Fred Swartz MIT License
Read File in Java
Read File in Java This tutorial shows you how to read file in Java. Example... java.io.FileReader is used to read the character files. This class takes file name as a parameter. This class is used to read the character input stream. So this class
Write a MoveFirst() for Circular Linked List
Write a MoveFirst() for Circular Linked List  write a MoveFirst(T elt) method to point the head at that element. Then the tail would point...); it should read "two three four one
Java read multiple files
Java read multiple files In this section you will learn how to read the data of multiple files. Here we have created four files that includes information... and write all the information of the students belongs to same school
Java Read File Line by Line - Java Tutorial
Tutorial you will learn how to write java program to read file line by line. We... output stream to write data that can later be read by a data input stream. Data... Java Read File Line by Line - Java Tutorial
read a positive real numbers from highest to lowest
read a positive real numbers from highest to lowest  write a java program that will read a sequence of 10 positive real nos. entered by the user and will print the same numbers in sorted order from lowest to highest using arrays
What do you mean by Repeatable Read?
What do you mean by Repeatable Read?  What do you mean by Repeatable Read?   Hi, The Repeatable Read isolation level allows a transaction to acquire read locks on all rows of data it returns to an application
Write Text into File
Write Text into File      ... this example we are initialize string to write into file. We are creating file in which we are writing string by use of write() method. We need  java.io.
JavaScript write to text file
a TextStream object to read from or write to the file. The Boolean value defined... JavaScript write to text file  ... are going to create a file and write text into it using JavaScript. In the given example
What do you mean by Read Committed?
when it commits. The Read Committed isolation level allows a transaction to acquire a read lock (if it only reads the data) or a write lock (if it updates...What do you mean by Read Committed?  What do you mean by Read
Excel sheet in read only mode - WebSevices
sheet,It has both read and write permission. How can i make the excel sheet to open in read and write mode so that user can edit it. I am using Java...Excel sheet in read only mode  If am opening an excel sheet(through
How to make a file read-only
the write permission of the same file. The method createFile creates a file with a specified name and setWritable(false) revoke the write persmission.. The method canWrite() returns booleasn value which whether the file is write-able
Read file into byte array java code eample
Read file into byte array java code eample  Hi, I have a project where I have to write for that reads file into byte array. I want a code java code for reading file into byte. Just let's know the best code. Thanks   
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
Java Write To InputStream
in FileOutputStream instance to write the contents that are read from...Java Write To InputStream In this tutorial you will learn how to write to InputStream in java. Write to file from InputStream in java you may use
What is the best way to write to file in Java?
;Read the tutorial at Java Write To File - Java Tutorial. Thanks...What is the best way to write to file in Java?  I am creating... to write to a text file in Java? Since my program will continuously write the data
How to make a file read-only in java
How to make a file read-only in java A read-only file is any file with the read-only attribute. Read-only files can be opened and accessed but you... a file read-only by using file.setReadOnly() method of File class. After using
Write Text File to Table
Write Text File to Table       In this section, you will learn how to read the records of a simple text file and write (insert) into a simple table in MySQL
How to read big file line by line in java?
Learn how to write a program in java for reading big text file line by line In this tutorial I will explain you how you can read big file line by line... will be able to read big size such as 5GB, 10GB or more. Many times you may have
How to write a session code - Java Beginners
How to write a session code   Once Again Thanks Deepak...Thanks... to write a session code plz write a session code and post answer my personal id... ------------------------------------------------- Read for more information
Java Write To File From FileInputStream
in FileOutputStream instance to write the contents that are read from the existing...Java Write To File From FileInputStream In this tutorial you will learn how to write to file from FileInputStream. Write to file from FileInputStream in java
how to write Session Handling - Java Beginners
how to write Session Handling  can any one please help me....how to handle Sessions .. in java Programs... with example  Hi friend, Read for more information with example at: http://www.roseindia.net/servlets
Java Write To File - Java Tutorial
of OutputStreamWriter class that is used to write text (as opposed to binary data... an internal FileOutputStream to write bytes to the specified file BufferedWriter : The BufferedWriter class is used to write text

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.