This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to split file?

 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 221
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dude i have added a new code below...
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 221
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, this works perfectly!

But I have one question. What's the lsize in the constructor about?
 
Winston Gutkowski
Bartender
Pie
Posts: 9484
50
Eclipse IDE Hibernate Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jenthe Marien
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic