
i have done the following code but the every time i write to the single file i get an empty text file can you guide me how to do this:
/*this program reads multiple files
* from a single directory. */
package elite.tech.com;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
public class reader {
static String inpath = "C:\\Users\\ndayala\\asc";
static String outpath = "C:\\Users\\ndayala\\bin\\bin.txt";
public static void main(String[]args) throws IOException{
File Folder = new File(inpath);
File files[];
files = Folder.listFiles();
if(files.length>1)
{
for(int i = 0;i<files.length; i++){
System.out.println("reading...");
System.out.println(files[i]);
Reader in = new FileReader(files[i]);
Writer out = new FileWriter(outpath , false);
// should be in finally block
in.close();
out.close();
}
}
else{
System.out.println("found only one file...");
System.out.println(files);
}
}
}

Please visit the following link:
http://www.roseindia.net/tutorial/java/core/files/fileconcatenation.html

thank you so much got it
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.