i had to concatenate thousands of files which are included in sub directories. after that gooled and collect some java codes , i coded as bellow.
in here ,All files concat to concat.txt file
import java.io.*;
public class ConcatenatedFiles {
public static PrintWriter pw;
static public void main(String arg[]) throws java.io.IOException {
pw = new PrintWriter(new FileOutputStream("C:/concat.txt")); // out fut file name and location
recuriceFiles("G:/smslist/"); // folder which is include all file for concatenate
pw.close();
System.out.println("All files have been concatenated into concat.txt");
}
static void recuriceFiles(String folderName) throws java.io.IOException
{
if(! new File(folderName).isFile())
{
File file = new File(folderName);
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if(! new File(""+files[i].getPath()).isFile()){
recuriceFiles(files[i].getPath());
}else {
concatFile(files[i]);
}
}
}else{
}
}
static void concatFile(File filename) throws java.io.IOException{
BufferedReader br = new BufferedReader(new FileReader(filename.getPath()));
String line = br.readLine();
while (line != null) {
pw.println(line);
line = br.readLine();
}
br.close();
}
}
Monday, October 3, 2011
Subscribe to:
Posts (Atom)
To configure Nginx for a Laravel application located within a subfolder, a location block is required to handle requests to that specifi...
-
define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', true); @ini_set( 'display_er...
-
I planned to held online practical exams for students who must save their result data on remote samba server. This tutorial ex...
-
In /etc/nginx/sites-available server { client_max_body_size 128m; } location ~ \.php$ { fastcgi_param PHP_V...