File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to split file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to split file?" Watch "how to split file?" New topic
Author

how to split file?

vinoth sathiyamoorthy
Ranch Hand

Joined: Sep 30, 2008
Posts: 31
Hi friends,

I want to split a file(text or doc or any) into some parts.not the content in a file.

eg. test.doc

split into test.doc.part1,test.doc.part2 and test.doc.part3.

any one can help me what coding is used to split a file?


Thanks in advance.

vinoth.
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
Dude i have added a new code below...

SCJP 1.5
"A candle looses nothing by lighting another candle"
itechmentors.com
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Too difficult a topic for us beginners. Moving.

And Vinoth KRM please confirm that is your real name, not an abbreviation.
vinoth sathiyamoorthy
Ranch Hand

Joined: Sep 30, 2008
Posts: 31
Thanks harilal ithikkat ,

In my coding:

try
{

FileDialog fd=new FileDialog(this,"Open",FileDialog.LOAD);
fd.show();
FileInputStream fos=new FileInputStream(fd.getDirectory()+fd.getFile());
System.out.println("File Location::"+fd.getDirectory()+fd.getFile());
int b;
st="";
while((b=fos.read())!=-1)
{
st+=(char)b;
}


How to combine your coding to above my coding?

if i call (splitFile(,,,);)to my coding means it will caught an error?
please tell me how to use?

thanks in advance.
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
Split

Merge



Check it now..i have tried it using Placement.doc
i splitted it to 5 files and Merged it to Temp.doc.
It worked well



nupur aggarwal
Greenhorn

Joined: Sep 16, 2012
Posts: 2
i am able to split files.
but am not able to merge the files.it says system cannot find the file path specified.
i have made the temp folder which contains all the file chunks as osrepfinal1.splt,osrepfinal2.splt......5 files.
i am not able to identify the mistake in the line : String fname = "temp\\osrepfinallt";
as is given in the above code String fname = "temp\\placementlt";
please replay asap.need it urgently for a project.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Welcome to the Ranch

There is no such thing as urgent here. Are those the relative or absolute paths to your files? If the file name ends with a number, why is the String you showed different?
nupur aggarwal
Greenhorn

Joined: Sep 16, 2012
Posts: 2
actually i tried a lot to access the chunks but was unable to.nyways i got another code for merging the files.thanks...
Jenthe Marien
Greenhorn

Joined: Oct 26, 2012
Posts: 2
Thanks, this works perfectly!

But I have one question. What's the lsize in the constructor about?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8251
    
  23

Jenthe Marien wrote:Thanks, this works perfectly!
But I have one question. What's the lsize in the constructor about?

It appears to be a "chunk size", but to be honest, the program is badly documented (and, I hate to say, written), so I wouldn't stake my life on it.

BTW (as was pointed out to me), the original post is more than 2 years old, so I suspect Elvis has left the building.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jenthe Marien
Greenhorn

Joined: Oct 26, 2012
Posts: 2
Winston Gutkowski wrote:
Jenthe Marien wrote:Thanks, this works perfectly!
But I have one question. What's the lsize in the constructor about?

It appears to be a "chunk size", but to be honest, the program is badly documented (and, I hate to say, written), so I wouldn't stake my life on it.

BTW (as was pointed out to me), the original post is more than 2 years old, so I suspect Elvis has left the building.

Winston


Winston, indeed this program isn't that well written.

I know am using another method (http://all-aboutl.blogspot.be/2012/06/how-to-split-large-files-into-smaller.html) and this is apparently working much better.

Thanks for your response anyway!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to split file?