hi friends i need help from you...

i need java code for moving first line from several MS word documents to one MS word document..[
[103 byte] By [josh@ajnousha] at [2007-11-26 22:22:05]
# 1
You already asked about that in your other thread: http://forum.java.sun.com/thread.jspa?threadID=5148561
kajbja at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 2
Oh, and why would we write code for you? We aren't the ones that are trying to get the job. What would your employer say if he found out that you hadn't written the code?
kajbja at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 3
they only asked me to find code from this site, because here i m the first person involved in development .. tts why.. could u help me?
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 4
s of course..i m new to this .. i don know how to operate.. now i corrected.. ok any idea about how to do tt program
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 5

//Description:you can copy the files specified extension from one folder to another as a text files or same extension.

//Code:

import java .io.*;

import java.util.*;

class Ext implements FilenameFilter

{

String ext;

public Ext(String ext)

{

this.ext="."+ext;

}

public boolean accept(File dir,String name)

{

return name.endsWith(ext);

}

}

class InputFileDeclared {

FileInputStream in;

public InputFileDeclared(String filename) throws FileNotFoundException {

in = new FileInputStream(filename);

}

public String getWord() throws IOException {

int c;

StringBuffer buf = new StringBuffer();

do {

c = in.read();

buf.append((char) c);

} while (c != -1);

return buf.toString();

}

}

public class FileReadWrite

{

public static void main(String as[]) throws IOException

{

//enter the path here

String srcDir="C:/bibu/finalcut2/";

String desDir="C:/bibu/outf/";

File f1=new File(srcDir);

FilenameFilter only = new Ext("doc");// file extension

String s[]=f1.list(only);

String de[]=f1.list(only);

System.out.println(s.length);

for(int i=0;i<s.length;i++)

{

try

{

s=srcDir+s;

System.out.println(s);

InputFileDeclared file = new InputFileDeclared(s);

String show=file.getWord();

String cpydst=(desDir+de);

FileWriter out = new FileWriter(cpydst);

System.out.println(cpydst);

out.write(show);

show=null;

out.close();

}

catch(Exception e)

{

System.out.println(e);

}

}

}

}

this s the code i m doing modification.. i m trying out deeply, because i m beginner, if u don mine do this for me plzchange this code to read first line only&write into only one document...>

josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 6
your question is still strange. hope i got it rite. do you want to get the 1st line of the txt document and print the same line into another text document?
lrngjavaa at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 7
yes you are correct.. can u plz do this for me?Message was edited by: josh@ajnoush
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 8

import java.util.Scanner;

import java.io.*;

class NamedFileInOut

{

public static void main (String[] args) throws IOException

{

int num, square;

// Scanner for user input

Scanner user = new Scanner( System.in );

String inputFileName, outputFileName;

// prepare the input file

System.out.print("Input File Name: ");

inputfileName = user.nextLine().trim();

File input = new File( fileName );

Scanner scan = new Scanner( input );

// prepare the output file

System.out.print("Output File Name: ");

outputfileName = user.nextLine().trim();

File output = new File( fileName );

PrintStream print = new PrintStream( output );

// processing loop

while( scan.hasNextInt() )

{

num = scan.nextInt();

square = num * num ;

print.println("The square of " + num + " is " + square);

}

// close the output file

print.close();

}

}

now you can do whatever you want to just a demo. instead of using numbers try to break it in string array and read line and then output

lrngjavaa at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 9
sory for disturbing again... plz do me a favour.. help me to do this project
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 10
> sory for disturbing again... plz do me a favour..> help me to do this projectBut I'm le tired. So, No. Good luck with that job.#
duckbilla at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 11
thank you, this code s for moving line from single document....but i need to write code for moving first line from all documents(nearly 30 to 50)to one document...
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 12
yes thank u... but i need to write code for moving first line from all document in specified location(nearly 45 to 60)documents)...to a single document
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 13
thank you, this code s for moving line from single document....but i need to write code for moving first line from all documents(nearly 30 to 50)to one document...
josh@ajnousha at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 14

> yes thank u... but i need to write code for moving

> first line from all document in specified

> location(nearly 45 to 60)documents)...to a single

> document

1) Open each document using Word.

2) Open a new Word document using Word.

3) Copy the first line of each of the Word documents opened in 1) to the new Word document opened in 2).

4) Close all Word documents.

Should take about 15 minutes. Much quicker than trying to program it in Java. Much quicker than asking for code in a Java forum.

sabre150a at 2007-7-10 11:20:18 > top of Java-index,Java Essentials,New To Java...
# 15
thank you, this code s for moving line from single document....but i need to write code for moving first line from all documents(nearly 30 to 50)to one document...
josh@ajnousha at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...
# 16
you r correct but i should do this using java... b'cause they(employer)have given this project to test my ability
josh@ajnousha at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...
# 17
> you r correct but i should do this using java...> b'cause they(employer)have given this project to> test my abilityAnd at the moment your ability is ....
sabre150a at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...
# 18
actually am a beginner, but i have finished 75%of my project, so remaining.... i don knoe how to do, tts y am asking? could u help me?
josh@ajnousha at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...
# 19
> actually am a beginner, but i have finished 75%of my> project, so remaining.... i don knoe how to do, tts y> am asking? could u help me? http://radio.javaranch.com/val/2004/10/16/1097909528000.html
sabre150a at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...
# 20

no compilation error in this,, but it does not supporting MSWord file... but i need to read content from MS word only? could u plz correct this..? Another problem..(while running this program ,i can get only the last file content.. ...but i need all file content in destinatin file...)

//Description: you can copy the files specified extension from one folder to another as a text files or same extension.(reading first line)

//Code:

import java .io.*;

import java.util.*;

//import java.io.BufferedReader;

import java.io.FileReader;

class Ext implements FilenameFilter

{

String ext;

public Ext(String ext)

{

this.ext="."+ext;

}

public boolean accept(File dir,String name)

{

return name.endsWith(ext);

}

}

/* class InputFileDeclared {

FileInputStream in;

public InputFileDeclared(String filename) throws FileNotFoundException {

in = new FileInputStream(filename);

}

public String getWord() throws IOException {

int c;

StringBuffer buf = new StringBuffer();

do {

c = in.read();

buf.append((char) c);

} while (c != -1);

return buf.toString();

}

} */

public class ajosh2

{

public static void main(String as[]) throws IOException

{

String srcDir="C:/josh/test/";

String desDir="F:/merge.doc";

File f1=new File(srcDir);

FilenameFilter only = new Ext("doc");//file extention

String s[]=f1.list(only);

String de[]=f1.list(only);

File f2=new File(desDir);

System.out.println(s.length);

for(int i=0;i<s.length;i++)

{

try

{

s=srcDir+s;

System.out.println(s);

BufferedWriter out = new BufferedWriter(new FileWriter(f2));

// InputFileDeclared file = new InputFileDeclared(s);

BufferedReader in = new BufferedReader(new FileReader(s));

//String show=file.getWord();

//String cpydst=(f2+de);

//File f2=new File(desDir);

//FileWriter out = new FileWriter(f2);//instead cpydst

// System.out.println(cpydst);

out.write(in.readLine()+"\n");

in.close();

//show = null;

out.close();

}

catch(Exception e)

{

System.out.println(e);

}

}

}

}>

josh@ajnousha at 2007-7-21 18:41:53 > top of Java-index,Java Essentials,New To Java...