I am losing my mind with the Null pointer topic

Please please help I want to go home
Need to split file into equal sized subfiles, the number of subfiles specified by the user
import java.io.*;
import java.util.*;
public class SpecifyFiles
public static void main (String [] args)
    try //try 1
//open input stream
File inputFile = new File(Input.readString("Input Filename:"));
InputStream inStream = new FileInputStream(inputFile);
InputStreamReader inreader = new InputStreamReader(inStream, "8859_1");
BufferedReader reader = new BufferedReader(inreader);
int numOutputFiles = Input.readInt("How many files?:");
//open output streams
for (int j = 0; j < numOutputFiles; j++) // for loop 1
OutputStream fout= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout= new BufferedOutputStream(fout);
OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1");
OutputStreamWriter [] fileHandles = new OutputStreamWriter[numOutputFiles];
int fileLength = (int)inputFile.length();
int newFileSize = fileLength/numOutputFiles;
byte [] byteArray = new byte [fileLength];
System.out.println(newFileSize);
//read data in and display them
inStream.read (byteArray);
//initialise the array of bytes
for (int a = 0; a < numOutputFiles; a++) // for loop 2
    fileHandles[a] = out;
   for (int i = (a*newFileSize); i < (a+1)*newFileSize; i++) //for loop 3
          out.write(byteArray);
} // for loop 2
out.close();
} //for loop 1
} catch (Exception ey) { ey.printStackTrace(); }
PROBLEM: IT IS ONLY PRINTING TO THE FIRST OUTPUT FILE

Yes. I have other code where the number of files the user wants is specified in the program itself, and that works perfectly.
If you see the code below, it splits a file into 5 separate files of equal byte size.
The only thing I want to change is that the user can specify the number of output files, and the program automatically prints the new separate files to that number of output files.
import java.io.*;
import java.util.*;
public class FileSplitter5
public static void main (String [] args)
try
//open input stream
File inputFile = new File(Input.readString("Input Filename:"));
InputStream inStream = new FileInputStream(inputFile);
InputStreamReader inreader = new InputStreamReader(inStream, "8859_1");
BufferedReader reader = new BufferedReader(inreader);
int numOutputFiles = 5;
//open output stream
OutputStream fout= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout= new BufferedOutputStream(fout);
OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1");
OutputStream fout1= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout1= new BufferedOutputStream(fout1);
OutputStreamWriter out1 = new OutputStreamWriter(bout1, "8859_1");
OutputStream fout2= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout2= new BufferedOutputStream(fout2);
OutputStreamWriter out2 = new OutputStreamWriter(bout2, "8859_1");
OutputStream fout3= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout3= new BufferedOutputStream(fout3);
OutputStreamWriter out3 = new OutputStreamWriter(bout3, "8859_1");
OutputStream fout4= new FileOutputStream(Input.readString("Output Filename:"));
OutputStream bout4= new BufferedOutputStream(fout4);
OutputStreamWriter out4 = new OutputStreamWriter(bout4, "8859_1");
OutputStreamWriter [] fileHandles = {out, out1, out2, out3, out4};
int fileLength = (int)inputFile.length();
int newFileSize = fileLength/numOutputFiles;
byte [] byteArray = new byte [fileLength];
System.out.println(newFileSize);
//read data in and display them
inStream.read (byteArray);
//initialise the array of bytes
for (int a = 0; a < 5; a++)
     for (int i = (a*newFileSize); i < (a+1)*newFileSize; i++)
         fileHandles[a].write(byteArray);
out.close();
out1.close();
out2.close();
out3.close();
out4.close();
catch (Exception ex) { ex.printStackTrace(); }

Similar Messages

  • Please help, i am losing my mind with the highlighting on my project

    when i view my project in iDVD, it looks fine, but when i burn a copy and try to watch it on my tv, the highlighting for the buttons isn't working properly. the highlighted text does not line up with the button and you can see 2 overlapping words in 2 different colors. this happens regardless if i use the T for text or the button for any particular theme. when the button is highlighted, the cursor/highlighted word looks like a mess...

    Hello, I had similar problem when some of my chapters cant be clicked on, my problem was the way I was spacing the chapters on a page, sometimes when they are close to each other, it would not be able to highlight at all. Maybe they way you spaced your chapters. I dont know if that will help at all, but it just my thought.

  • Hi...i'm still using the old iphone 3G...my phone is no longer charging...when i tried to charge it, what i see on the screen is the usb cord with the arrow pointing the itunes logo...can someone help me?

    hi...i'm still using the old iphone 3G...my phone is no longer charging...when i tried to charge it, what i see on the screen is the usb cord with the arrow pointing the itunes logo...can someone help me?

    It sounds like your phone is in recovery mode, which means it needs to be restored through iTunes on your computer in order to get out of it.

  • HT204318 Copied my iTunes from my Mac to my Windows 7 laptop, now there are thousands of songs missing on the Windows copy with the exclamation point.

    Copied my iTunes from my Mac to my Windows 7 laptop, now there are thousands of songs missing on the Windows copy with the exclamation point. everything shows up, playlists and tracks, there are just a bunch of songs with exclamation points. how can i properly sync my iTunes from my Mac to my PC? using iTunes

    Moving a library: Quick answer if you use iTunes' default preferences settings:  Copy the entire iTunes folder (and in doing so all its sub-folders and files) intact to the other drive.  Hold down the option (alt) key (shift on Windows) and open iTunes.  At the prompt to create or choose a library choose the copied iTunes folder.

  • HT204318 Copied my iTunes from my Mac to my Windows 7 laptop, now there are thousands of songs missing on the Windows copy with the exclamation point. everything shows up, playlists and tracks, there are just a bunch of songs with exclamation points. how

    Copied my iTunes from my Mac to my Windows 7 laptop, now there are thousands of songs missing on the Windows copy with the exclamation point. everything shows up, playlists and tracks, there are just a bunch of songs with exclamation points. how can i properly sync my iTunes from my Mac to my PC? using iTunes

    nope all my songs are copied and organized into the iTunes library.

  • Cannot associate with the access point error message

    We just got high-speed Internet installed at our house. We have a cable coming into the house that connects to a Linksys WAP54G router in our basement. We have two Dell Dimension computers that we installed Linksys PCI Wireless G Cards into. The computer down the basement is working just fine. The computer upstairs which is directly above the router worked fine the first day. The computer got powered down and upon restart wouldn't connect again. I did a system restore and it worked fine. Windows errored out yesterday, and now even after doing a restore, I cannot get it to connect to the wireless network. The error message "Cannot Associate with the Access Point" comes up. When you search for available wireless networks, none appear. Any ideas?

    Try connecting to the network using the Wireless Zero Configuration...just checkout on the right-hand side bottom of the screen pc right-click the Wireless network connetion icon...click view available wireless networks...click refresh network list...on the same list you will see Change the order of preferred networks...on top of the page click wireless networks...in preferred networks...remove each & every network...click OK. Now, once again right-click the Wireless network connetion icon on right-hand side bottom of the screen & click view available wireless networks...click refresh network list...now you will be able to see your wireless network..if its a secured network it will ask you for the wireless wep key...put in the key...where it says confirm the network key & click connect...it will be CONNECTED....and you will be able to go ONLINE WIRELESSLY!!!

  • Can not associate with the access point

    Greetings!
    I am just new here. I am trying to set-up a wireless connection from our linksys router. I recently purchased a linksys wireless internet receiver thru USB connection. Now, my problem is the pc that is supposed to receive a wireless connection is stating " can not associate with the access point". I am not too good about computers, that is why I am seeking you help.
    I hope I can hear from you guys.
    Thanks in advance.
    Cheers!
    Square

    Lets start with the bad news, no wireless connection. Good news, fixable.
    Make sure all your security settings on the usb adapter are correct. If router is set for wep set adapter to wep,and so on. Also check all your firewalls, in windows, and on any virus suites that you may have running. Try turning off all firewalls, other than router, and see if that helps. Also download the easy link advisor from the linksys home page. Make sure your ssid, and network names are set the same for router, and adapter.
    Stlbluesfan30
    Cisco Network Academy Student

  • My ipod classic got knocked off it's dock by my cat and now no matter what I do, even try to charge it I only get sad face with the exclamation point and it clicks like a clock...Is it hopeless?

    My ipod classic got knocked off it"s dock by my cat.  Now no matter what I do I only get the sad face with the exclamation point, even when I try to charge it.  Is it hopeless?

    Yes, it's likely that the iPod's hard drive is damaged and is in need of replacement.
    B-rock

  • The screen with the plug pointed to itunes is frozen and my computer will not recognize the ipod

    The screen on my ipod touch has a pic with the plug pointed to the itunes logo and it is frozen.  The computer will not recognize the ipod anymore.  I had updated the itunes to the latest version and the it was in the process of updating software in the ipod.  It said that the download could not be completed.  This is a new ipod touch.

    See here for...
    Device Not Recognised
    For PC
    http://support.apple.com/kb/TS1538
    For the download to complete error...
    Try temporarily disabling your firewall and antivirus software and try again...
    See here for Connection Issues
    http://support.apple.com/kb/TS1379
    From Here
    http://www.apple.com/support/itunes/troubleshooting/

  • How can I get "IMAQ Line Fit" stable (with the same points)

    How can I get "IMAQ Line Fit" stable (with the same points)
    I my vision applications I use a lot off times "IMAQ Line Fit"
    some times the results are not Stable.
    See vi and word document attached.
    When I take the same points but in a other order (sort)
    then suddenly all points are used.
    In this case I was looking for a edge in vertical direction (Y).
    I found the points but "IMAQ Line Fit" did not function well.
    I tried changing all settings like pixel radius and minimum score and
    also threshold and so on. But no result.
    Then I sorted the points reversed and that worked. See vi.
    I use labview Labview 8.6.0 and IMAQ machine vision.
    Maybe this problem is solved in a newer version.
    Please let me know.
    Thanks
    Attachments:
    TEST-imaq-line-fit-86.vi ‏169 KB
    IMAQ-Fit-Line-Problem-86.doc ‏230 KB

    Thank You for your reaction Hossein,
    This "one application" uses "Line fit" about 20 000 000 times a day.
    about 200 will go wrong. With your setting the the "Line fit" for this occasion will work but others will go wrong.
    A algorithm should be:
    1e Stable, when using the same points and settings the result MUST be the same. How the points are sorted should not matter.
    2e Accuracy
    3e Speed
    4e Testing. Is very difficult but al least close points and the same points and sorting ... should be done
    NI now as made a " IMAQ Line Fit" Problem CAR (Corrective Action request) 298016.
    so in the future there will be a update.
    In the mean while a made a line fit which uses Bisquare option from Linear Fit.vi :
      from C:\Program Files\National Instruments\LabVIEW 8.6\vi.lib\analysis\6fits.llb
    This is a temporary fix because "IMAQ Fit Line VI" is not so stable.
    Because outliers should be rejected only Bisquare does this reasonable.
    This program does NOT USE "Minimum Score" and "Pixel Radius"
    Valid fit = When there are enough points within Outlier_Distance.
    Algorithm steps:
    - Determine if line is more horizontal then vertical, Compare DeltaX with DeltaY
    - If DeltaX <= DeltaY then SWAP X Y and later Swap back
    - Sort Points at on X value
    - First : Bisquare Linear Fit
    - Calculate distances to the found line for all points
    - Inliers: Points within Outlier_distance
    - Outliers: Points outside Outlier_Distance
    - Only use Inlier Points
    - Check again if DeltaX < DeltaY then SWAP X Y later SWAP back again
    - Second : Bisquare Linear Fit only with the Inlier Points
    - Results are from the second fit
    Warning : This Program is Not so accurate and Not so fast
    See attachments it is in labview 8.6
    If some has a improvement please let me know.
    Thanks
    Attachments:
    svi_fit_line_Bsquare_and_draw.vi ‏18 KB
    Fit_Line_Bisquare_Linear.vi ‏40 KB

  • HELP!!!!!!!!!!! I AM LOSING MY MIND WITH MAIL!!!!!!!!!!!!

    Can someone please help me!!!!!! I have been using mail for 8 months, then all of a sudden I started to get this error "The SMTP server “plus.smtp.mail.yahoo.com” rejected the password for user “[email protected]” I have check all passwords, and settings.. still won't accept it.. I am not sure what I am doing wrong or miss.. won't send and now I am not receving my mail from Gmail either, and I just set it up// losing my mind.. not sure what to do... and the people at the Apple store here not fully understanding as.. German is their first language....HELP ME!!!!!

    I would do the following:
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger and Leopard.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer. Now restart normally.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger, and 4.1 for Leopard) and/or TechTool Pro (4.6.1 for Leopard) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Try removing the com.apple.mail.plist file from your /Home/Library/Preferences/ folder. Don't delete it but rather put it somewhere else such as your Desktop. Make a backup of your /Home/Library/Mail/ folder just in case.
    Then reconfigure Mail. Your accounts should still be there so nothing you have stored on the computer should be lost.

  • When i login into my terminal..it starts with the null before my username...it has happened only recently

    Last login: Tue Aug 16 19:11:15 on ttys000
    (null):~ Saurabh$
    Please see the null above..can you tell me what is wrong here..i am a first time mac user...

    i used the command scutil to set the hostname and have gotten rid of this minor issue

  • Mastering but losing my mind with a "gap" between 2 tracks which shouldn't be there. What is wrong?

    I have an album which I've been working on for a while and it's now all finished with the exception of one small glitch...
    Throughout the album I have a around 4 overlapping tracks, when burning the tracks to a disc, 3 out of 4 of the tracks crossover into the next track perfectly. 1 of them doesn't...
    My 1st method: Paste the 2nd Track over the end of the 1st Track, then cut the 2nd overlapped track and paste back over the original 2nd track, whilst saving over the now shortened 1st track... ( This, whilst not a great method, has never failed me in the past and worked on the the other overlapping tracks).
    So I realised this wasn't a great method so then tried method 2.
    My 2nd Method: Drop all the mixdowns into one waveform (in Edit view), and create Markers using the Marker List and F8, so that each track starts bang on the next .001 of a second.
    Again, for 3 out of the 4 this was fine, but for the other... I can still her the tiniest click!
    It's a click the listener will not notice, but it's a click that is killing me because the label putting out the CD is on me to get the final mix to them, but I won't submit it until this click has gone.
    Things I should note:
    1. When played in Winamp, there are no clicks. This is ONLY when burnt to a disc.
    2. I've used Adobe Audition 3.0 to burn the audio disc with no silence between tracks.
    3. I've also used Nero to burn the audio disc with no silence between tracks.
    4. I've used multiple computers/dvd burners to test this.
    5. I've used multiple brands of CD-rs.
    6. I'm very sure that there is not an actually cilck on the waveform.
    7. This is the 1st track leading into the 2nd track (I'm aware there is a 2 second gap before the 1st Track)
    8. I've played the burnt CD-r on my PC, my DVD player, my Computer at work, my car stereo.
    Please help me with this, it's driving me nuts as I've worked very hard and perfected the thing, and need to submit it very soon.
    Is there any software you would reccomed to split tracks which I should try?
    Thank you!

    CD tracks should not be starting on the nearest .001 of a second but 1/75 of a second. The CD standard is 75 frames per second. If tracks do not start on the nearest 1/75 of a second the audio will be filled out to the nearest one causing clicks at the junctions. Make sure that the Display Time Format is set to Compact Disc 75fps and that Snap to Frames is turned on.

  • Issue with the change pointer  for the reduced message type ZMATMAS

    Hi All,
    I have created reduced message type ZMATMAS for the MATMAS to create a Idoc when change or insert material master data fields( MARA-LAENG, MARA-BREIT, MARA-HOEHE) . My Problem is that the Idoc is generated with the status (03) but the fields(LAENG, BREIT,HOEHE)  are not getting fill with the values. They are always filling with the values  '/'). I have done the following steps to create idoc for the change pointer. Please check whether i have missed some steps.
    1.     Create reduction maintenance ZMATMAS  (Tcode BD53)
    keep the default selected segments E1MARAM, E1MAKTM
    2.     Add following data to maintain table view for the message type ZMATMAS  (Tcode BD52)
    Object      Table Name     Field Name
    MATERIAL       MARA      KEY
    MATERIAL     MARA     LAENG
    MATERIAL     MARA     BREIT
    MATERIAL     MARA     HOEHE
    3.     Activate particular change pointer in BD50
    Message Type       Active
    ZMATMAS         yes
    4.     Activate change pointers u2013 Generally (Tcode BD61).
    5.     Assign Segment fields to change document fields (Tcode BD66 )
    Segment Type     Field Name     Object     Table Name     Field Name
    E1MARAM     BREIT     MATERIAL     MARA     BREIT
    E1MARAM     HOEHE     MATERIAL     MARA     HOEHE
    E1MARAM     LAENG     MATERIAL     MARA     LAENG
    6. I have done the distribution model settings (BD64) and  the idoc configurations
    1.     Logical System
    2.     RFC destination
    3.     Create port
    4.     Create partner profile
    7. I changed the fields in material master data(Tcode MM02)  and I executed the Tcode BD21.
    Idoc is generated but the fields are not getting fill with the values
    (Note: some fields  are filled with values e. g material number, material description)
    I checked the Idoc data segment E1MARAM (WE02)
    Fld name   Fld cont.
    LAENG       /
    BREIT       /
    HOEHE      /
    Can you please let me know the issue
    Prad

    Issue is solved when I select the segments and the fields in the segments (Tcode :BD53)
    Prad

  • When trying to log back from sleep mode, the screen behaves as a rotating cube, with the mouse pointer in the top left corner. Hangs.

    iMac OS X Ver 10.7.3
    21.5 Inch, Mid 2011
    2.5 FHz intel Core 5
    12 GB 1333 MHz DDR3
    When the computer in woken from sleep mode we see two login options (bineg used by two users).
    But when we try to login, the screen just behaves as a sluggish rotating cube.
    Nothing works, we just have to hard boot at this time.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of this exercise is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login. Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Note: If FileVault is enabled under Mac OS X 10.7 or later, you can’t boot in safe mode.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

Maybe you are looking for