Join files again, after they're split into 1 kb chunks

I have the below code in my program. It splits a single file into multiple files each 1 kb in size that when put together in the right order will make up the original text file. Anyone got any ideas on how I can write a class to do this?
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.io.*;
import java.util.*;
import java.lang.Object;
public class Split
public Split ()throws Exception {
          File f = new File("\\Shared");
          //File tempFolder = new File("C:\\Temp\\");
          File files[] = f.listFiles();
          for(int i=0;i<files.length;i++)
               String path = "C:\\Shared\\";
               String fileName = path +files.getName();
               String fileName1 = files[i].getName();
               Do(fileName,fileName1);
//Splits files
          public static void Do(String fileName , String fileName1)throws Exception
               try{
               BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(fileName)));
               byte[] buffer = new byte[1024];
               int read;
               int c;
               int i = 0;
               while( (read = in.read(buffer)) > 0 ){ //-1 means EndOfStream     
                    if( read == buffer.length )
                         BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("C:\\Temp\\" + fileName1 + "_" + i));
                         out.write(buffer);
               out.flush();
               out.close();
               i++;
                    else
                         BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("C:\\Temp\\" + fileName1 + "_" + i));
                         out.write(buffer, 0, read);
                         out.flush();
                         out.close();               
               in.close();
                    }catch(IOException e){
                         System.out.println(e);
public static BufferedInputStream readFile(String name) throws Exception {
File file = new File(name);
FileInputStream fis = new FileInputStream(file);
return new BufferedInputStream(fis);
public static void writeFile(String name, byte[] bytes) throws Exception {
File file = new File(name);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream out = new BufferedOutputStream(fos);
out.write(bytes);
out.flush();
out.close();

What part are you having trouble with? If you have the code to split a file up, putting it back together again should be trivial.

Similar Messages

  • I would like to know if I can "join CD tracks" once they are downloaded into a playlist in my ITunes folder on my computer and/or how do you "join CD tracks" if you are downloading from iTunes itself.   I have two songs that I would like to "join" but I d

         I would like to know if I can "join CD tracks" once they are downloaded into a playlist in my ITunes folder on my computer and/or how do you "join CD tracks" if you are downloading from iTunes itself.   From the information through the "Help" menu, it seems you can only "join cd tracks" when you are in the process of downloading them from a CD onto your iTunes playlist?
    .....any suggestions would help.
    Thank You
    DW

    The help menu is correct.

  • Why firefox 3.6 downloads all of the files again after restartarting the browser from a website if the "clear history when Firefox closed" is not Enabled?

    We have a corporate website, we officially support FF3, FF4, IE8 and IE9. Our web site is quite big, so we really need browser caching, first time page load is around 15 seconds. With files in the cache getting new page is less than a second.
    Everything works perfect except with FF3. With FF4, IE8, IE9 if we are on the website, clicking everywhere is fast, the page is in the cache. If we restart the browser, it is still fast, it loads files from the cache.
    But with FF3 we have a problem. Every time we restart the browser, it is loading the files again from the server, instead of using the local cache (checked with Firebug). I can reproduce the problem anytime, it is the same with every FF3 instances. I double checked, the "clear history when Firefox closed" option is not enabled.
    Could you advise please how to use the local cache either after browser restart?
    Thank you!
    Chris

    Just read that the default memory storage on FF is set to 5 mbs. You can up that by clicking on tools, advanced and overriding the default and set it to 50 mbs (if you use lots of tabs) or 10 mbs (if you use just a few).
    I open a blank tab and clear the cache periodically, while I am working. I can have several tabs open and watch videos on Youtube, by doing this. Have you cleared your cache?
    Since I have an older computer, I've also used CCleaner for years. I use it often, but always before signing off. You can get it free...search for CCleaner, download from Pirifoam free. I didn't change any of the settings and it clears crap left behind from uninstalling programs, clears all browsers at once of: cookies, history, passwords, etc. I love it!
    I had freezing, before using the "open blank tab, clear the cache" thing. Now I have no problems. Plus, as I said...you can change the default memory usage for FF and that should help too.
    Hope this helps! Good luck! :)

  • Time Machine Copying all files again after a restore

    i recently achieved a successful restore of my computer and now i am wishing to back up my computer again (after installing bootcamp) but time machine keeps trying to backup all my files
    my computers name is still the same and when i force a backup the inprocess icon comes up in my external drive(where it should be) but then says there isnt enough space. it also seems to want to back more information then i have on my original hard drive?it also deleted my earlier backups without consent
    any help would be greatly appreciated

    I would imagine that reformatting the hard drive would remove the event logs that Time Machine uses to determine what has changed since the last backup and so it would be likely to fully backup from scratch. You should be able to view previous backups using the Browse Other Time Machine Volumes menu item in Time Machine given that your computer name is unchanged.

  • Covert file types After they are in library?

    I imported a couple audiophile gradeCD's and went completely loss-less. File sizes are massive of course, so now I want to convert them to 256k apple loss-less files.
    How do I do this After they are already in iTunes?
    I checked every menu apple offers, I can't find any way to change the file type unless I delete the files and put them back on the hard drive using the file type I want.
    I'm no mac pro yet, only switched solely to mac less than 2 months ago. Help?
    Message was edited by: 09minimac

    Just change your Import setting to whatever format you want to convert them to and select the option to Convert selection to xxxx. This used to be available by right-clicking the track, but I believe it is now under the Advanced menu (within the main iTunes interface).
    This will create a second file in the new format; you can then trash the huge file.
    And there's more info here: http://support.apple.com/kb/ht1550
    Message was edited by: Diane Wordsmith

  • Problems loading nib files after class is split into a static library.

    I've recently split a project so that the common re-usable controls are in their own class library. My original application project now references these using a cross project reference.
    However, since I have split the projects up, my original project crashes when it loads main.xib because it cannot find one of the custom classes which is defined in the library project.
    When I first split up the projects, I noticed that there were problems with the nib files not being able to find the IB outlets of the custom classes, but I managed to get around these by going importing the relevant library class files manually (File > Read Class Files…).
    I have made sure that all of the nib files compile without warning, so as far as I can tell, Interface Builder is able to read the necessary class headers, but when I try to run the app, it crashes saying that there is an unknown class in the Interface Builder file and that the class is not coding compliant.
    Are there any steps I've missed or advice on how to troubleshoot this?

    I did a bit of digging. The reason why this wasn't working is because the class in question was referenced by the nib files, but not in code. Therefore, while the code compiled and there were no warnings with the nib files, the linker was not linking the classes because no code used them directly.
    This can be fixed by going to the Project Settings, and on the Build tab, underneath the Linking heading, adding -ObjC to the Other Linker Flags section.

  • Dual headphone outputs... can they be split into 2 separate outputs?

    I just got a DV6-1214AX and want to use it for DJing and would like to be able to separate the dual headphone outputs so that they are 2 separate outputs (1 for headphone monitoring and cueing etc, the other for the main sound output) is this possible?
    If not, any suggestions on the best way to do what I'm after without needing to utilise the digital output for the main sound output??
    Any tips would be much appreciated.

    Thank you...I have been sitting here all morning working on it again and realized there was a way to do it manually that didn't require dragging and dropping the tabs....which it will not do.  Yikes!  Thank you for your response.
    Now I have realized there is a problem with the word doc in another field.  The spacing for a telephone number is wrong.  Is there anyway to change it in the form or do I have to go back to the word doc, fix it, then re-import it?  My desire to not do this is because I have to take it back to the original word doc and then when I re-import it, it obviously won't have all these changes I have just made.
    Deb

  • Where do files go after they are unzipped?

    I have downloaded a zip file that open up to a .pkg file. It is a user manual that is a .pdf file. When I go to look for it I can't find it anywhere on my computer. I have tried looking for it with spotlight using the file name but it is nowhere to be found. Please help. Thanks.

    It should reside in the same location as the .pkg file.
    Check the trash as well.

  • When I make a Smart Album, will the photos that match the Smart Album criteria still be present in their original location(s) in the Library after they go into the Smart Album?

    When I make a Smart Album in iPhoto, will the photos that meet the criteria of my Smart Album still be present in their original location in my Library after they are "brought into" the Smart Album?

    Yes.
    Iphoto works as a Library. Everything is in the Library, and albums (Smart or otherwise) reference the photos from the Library.
    Nother way to think about it: An Event is a place. An Album is a list...
    Regards
    TD

  • Issue with file to file in PI 7.3 (Splitting huge files)

    Hi All,
    Need your help in fixing the issue with file splitting
    We are doing some sample scenarios(file to file) on PI 7.3 server.
    We are trying to split a 10MB file by using the 'Advanced Mode' option in the sender file adapter. We gave max split file size as 2MB. The file got split into 5 chunks and was successfully sent to receiver file adapter. In receiver adapter we are able to see that. But in the target folder only 1 file was seen with size 2MB. All other chunks were missing. We need to have the whole data sent from source to target.
    How to fix this issue? please provide your inputs.
    Thanks and Regards,
    Lakshmi Narayana

    PI 7.3 has capable of processing larger size files.
    Questions:
    Have you picked EOIO quality of service? Hope you dont do mapping or content conversion for this file?
    have you seen this link
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a06d79f3-d094-2e10-1a81-f4d802d0bcf1?QuickLink=index&overridelayout=true
    http://help.sap.com/saphelp_nw73/helpdata/en/44/682BCD7F2A6D12E10000000A1553F6/frameset.htm

  • Alv output splitting into two rows when converting into excel sheet.

    Hi frends,
    I have alv report with 60 fields . The report output is coming currently .  But when i am exporting into excel sheet from the option local file--> speadsheet  each row is splitting into two rows including header in excel sheet.
    Please provide your valuable suggestions to avoid this.
    Regards,
    Ramu .
    Edited by: Ramu.K on Sep 8, 2009 5:59 PM

    Hi,
    Please use the grid option and with the Spreadsheet button (CntrShiftF7). Do  "Save as" and save it as excel. It should work.
    Regards,
    Pradyumna

  • When I set all the tracks in the latest Garageband to the same volume levels and save, when I open the file again they've changed back to a previous setting?

    I'm trying to mix a recording in the latest 2014 version of Garageband, but when I set all the tracks in the latest Garageband to the same volume levels and save, when I open the file again they've changed back to a previous setting? Does anyone know why it changes even after saving the file?
    Below is my iMac settings.

    Do you have a back up?
    If not you're into using file recovery software like  File Salvage - you can download a free trial and it will scan the disk for you and tell you with might be recoverable. Actual recovery will require that you purchase the app. There may be many files with the same or similar names. Always recover the largest file size.
    There are other such apps. Search on Macupdate or the App Store

  • After a PRAM reset my MBP 1,1 display is split into 4 parts each displaying the same image. What is causing this and how can I fix it?

    After resetting the PRAM/NVRAM (control, option, P, R) on my Macbook Pro 1,1 (2007) running 10.6.8 The screen is now split into 4 parts, each displaying the same thing. The screen immediately appears this way at the first grey screen, however if I do another NVRAM reset, upon restart after the second startup chime, the screen is normal but once it gets to a certain point around thetime the cog stops spinning, the screen flickers, turns blue and splits into four again.
    Another thing is when I tried using the Apple Hardware Test I couldn't read the instructions as the resolution was too small, but once I restarted and change my display resolution in System Preferences, the resolution was readable in AHT. I assumed the System Settings were loading when the OS had booted and that AHT runs without any of these settings (if that makes sense?)
    I've not used any third party utilites and everything working fine except for some battery issues which are gone now (the reason I tried the PRAM reset)
    Any help would be much appreciated

    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Press and hold Shift and left-click the Reload button.
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (MAC)
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Splitting large video files into small chunks and combining them

    Hi All,
    Thank you for viewing my thread. I have searched for hours but cannot find any information on this topic.
    I need to upload very large video files. The files can be something like 10GB in size, currently .mpeg format but they may be .mp4 format later on too.
    Since the files will be uploaded remotely using using internet from the clients mobile device (3G or 4G in UK) I need to split the files into smaller chunks. This way if there is a connection issue (very likely as the files are large) I can resume the upload without doing the whole 10gb again.
    My question is, what can I use to split a large file like 10Gb into smaller chunks like 200mb, upload the files and then combine them again? Is there a jar file that I can use. i cant install stuff like ffmpeg or JMF on the clients laptops.
    Thank you for your time.
    Kind regards,
    Imran

    There is a Unix command called split that does just that splits a file into chunks of a size you specify. When you want to put the bits bact together you use the command cat.
    If you are comfortable in the terminal you can look at the man page for split for more information.
    Both commands are data blind and work on binary as well as text files so I would think this should work for video but of course check it out to see if the restored file still works as video.
    regards

  • To open & Edit the XLS file in edit mode after Extracting SAP data into it

    Hello Experts,
      I have a requirement to open and edit the xls file imidiately after downlaoding the SAP data into this XLS file. The XLS file is getting saved on presentation server (e.g. Destop/C: drive).
      I have used function module "GUI_DOWNLOAD" OR "DOWNLAOD" to download the data from SAP table to XLS file. But now I need this XLS file to be get opned automatically after finishing the Download, so that user can make changes into XLS file and can save the changes into it. After saving I have to upload this modified Data into SAP table again.
    For this I am really not aware how to get it done..but I believe you experts will definately help me out..waiting for your reply.
    Thanks,

    HI,
    did you ur problem was solved if not check this code once.
    now only i tried it my system , it opens xl file and save all data in it.
    DATA: ZKNA1 LIKE STANDARD TABLE OF KNA1 WITH HEADER LINE.
    SELECT * FROM KNA1 INTO TABLE ZKNA1.
    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
      EXPORTING
        FILE_NAME                       = 'C:\Documents and Settings\rajesh.NACL\Desktop\XLSSDSDS.XLS'
      CREATE_PIVOT                    = 0
      DATA_SHEET_NAME                 = ' '
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
    TABLES
      PIVOT_FIELD_TAB                 =
       DATA_TAB                        = ZKNA1[]
      FIELDNAMES                      =
    EXCEPTIONS
      FILE_NOT_EXIST                  = 1
      FILENAME_EXPECTED               = 2
      COMMUNICATION_ERROR             = 3
      OLE_OBJECT_METHOD_ERROR         = 4
      OLE_OBJECT_PROPERTY_ERROR       = 5
      INVALID_PIVOT_FIELDS            = 6
      DOWNLOAD_PROBLEM                = 7
      OTHERS                          = 8
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    thanq,
    rajesh.k

Maybe you are looking for