0

hello all

i am doing a copy operation from a file to another file.in source file i have 13 digit no but in destination file there is only 12 digit copied.code is as follows.

public void createOriganalFile() {
        try {

            File ObjInputFile1 = new File(strFilepath + "_dummy.txt");
            File ObjOutputFile1 = new File(strFilepath);
            String strLine1 = "";
            BufferedReader ObjBufferReaderIn1 = new BufferedReader(new FileReader(ObjInputFile1));
            BufferedWriter ObjBufferReaderOut1 = new BufferedWriter(new FileWriter(ObjOutputFile1));
            do {
                if ((strLine1 = ObjBufferReaderIn1.readLine()) == null) {
                   System.out.println("strLine1 is null");
                    break;
                }
                System.out.println("strLine--------- " + strLine1 +"  strFilepath   " + strFilepath);
                ObjBufferReaderOut1.write(strLine1,0,13);
                ObjBufferReaderOut1.newLine();
                ObjBufferReaderOut1.flush();
                 System.out.println("Here After: "+strLine1);//13 digit no



            } while (true);
                
             //ObjInputFile.delete();
            ObjBufferReaderIn1.close();
            ObjBufferReaderOut1.close();
            ObjBufferReaderIn2.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by hfx642
0

Well, even though the Java Docs say that the write (string, start-index, length),
I'm guessing that it is similar to a substring, which is start-index, and the end-index (of what NOT to include).
Try changing it to "0, 14".
However... Why are you bothering with the "0, 13" at all?
Just do a write (string).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.