Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to split file?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dude i have added a new code below...
 
Marshal
Posts: 79530
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79530
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, this works perfectly!

But I have one question. What's the lsize in the constructor about?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is an old post which I stumbled upon via google search but for future reference of users I am putting the piece of code I used to split any large files to any size of chunks and join back them without any issues.
You can find the program here.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic