How to read a large file(size around 100 kbytes) into a byte array in JAVA

aa

But I cannot use array subscript as a long value.what do you mean?
are you rying the following:
long aSize = 100000;
byte[] array = new byte[aSize];
if this is the case, then don't do it, for your 100k file int is far more than enough.
but in case you jsut get error while:
byte b = array[100000];
then it's probably because you'r array is of size 100000, that means you have bytes from 0 to 99999 in there, and 100000 is one passed the end of the array.... jus in case make your array size to be 1234567 (far more than needed for your file) and see if you still get that exception, if not, then your array was too small. but if it fixes your prob, then don't leave it as it is, try to work out the right size for array and use that....
i wouldn't recommend using static array size, since that file might some day be bigger than you expected, and then you'd have to recompile your program.
HTH

Similar Messages

  • How to read an inputStream in UTF-8 into a byte array.

    Hi, Java version is 1.4.2. If inputStream.read() is used to read the bytes into a byte array, is it guarenteed that UTF-8 chars are correctly transferred into byte array? Or should we use InputStreamReader? An example would be a great help.
    Thanks in advance.

    I would like to send a byte array read from InputStream to another app where they are converted to UTF-8. In brief
    -Read input stream which comes in UTF-8 into a byte array
    -Send byte array to another app which will convert it into UTF-8 characters

  • How to reduce a PDF file size under Adobe Acrobat Reader DC. The size is now 23MB; I need it to be less than 4MB. thanks

    how to reduce a PDF file size under Adobe Acrobat Reader DC. The size is now 23MB; I need it to be less than 4MB. thanks

    I've found in Pdf's many time when you go to Optimize a PDF and look at the font list there are often up to a 1/2dozen copies of a given font, say Helvetica, then that many Helvetica Bold, or Arial or Ariel Italic
    What I do ie remove from list all but one copy of each different font. often dramatically reduces the size. also something lese is Flattening images will in some cases reduce a file size. I have run into a case where it actually made a PDF Larger.

  • When I import my Sony video, which is in m2ts format, the file size is a few times larger.  This affects the volume of clips for creating the blu-ray or DVD discs.  How can I squeeze the file size without sacrificing the quality of output?

    When I import my Sony video, which is in m2ts format, the file size is a few times larger.  This affects the volume of clips for creating the blu-ray or DVD discs.  How can I squeeze the file size without sacrificing the quality of output?  Is there any other ways of achieving this?

    wongrayd wrote:
    Thanks.  I do not have the experience on burning discs from iMovie for the movie after editing (ie for video discs players).  It seems that i cannot find the relevant command in the tool bar for this purpsoe.  Would you please show me the way?
    The command is gone because iDVD has been discontinued by Apple. After Apple discontinued iDVD they removed the iDVD burning link from iMovie. I still use iDVD sometimes, only because I have an old copy.
    wongrayd wrote:
    You have mentioned about Handbrake as a converter.  What is the RF no. (under Constant Quality) meant?  It seems that the smaller the no. is, the better quality will be.  What is the optimal no.? or should we use the Average Bitrate? Again, what is the best rate?  Furthermore, which format is more suitable or the best: H264 or mpeg 2/4?
    I don't know what RF means. When I have used HandBrake, I've used presets that apply to what I want to do, so I don't know the meaning of each individual setting. However, it appears that many of them are listed in the HandBrake User's Guide that is linked from the Help menu in the program:
    https://trac.handbrake.fr/wiki/HandBrakeGuide
    wongrayd wrote:
    For iMac, except iMovie, what other software is the best for the amateur?  I have read Photoshop.  Can this support m2ts files and user friendly?
    Photoshop is not amateur-level software, and although it can edit a video, it cannot burn a DVD. Unfortunately, because I still use iMovie, I haven't tried anything else. You might want to read the reviews of various DVD-burning applications in the Mac App Store.
    And maybe another forum member will jump in and help us here!

  • Need to get large file sizes down to downloadable sizes-how?

    I am using Compressor 4 and have several professional videos I produced with Final Cut Studio in QuickTime/.MOV format using ProRes 442. They are all 720p and of course, all have large file sizes. I needed to convert them so they are compatible with iTunes as well as Apple devices (AppleTV, iPad/iPod/iPhone, etc). They also need to be downloadable in a reasonable time and I of course want to maintain a quality image. Several of the videos are about an hour long, some a little more.
    I an unable to get most of these files to be small enough for practical download and still maintain an acceptable quality. For example:
    I have one video (QuickTime rendered from FCPS) that runs 54 minutes. 1280x720, ProRess 422, Linear PCM with a Bit rate of 72.662. The best I seem to be able to get out of compressor is to use the setting options for "HD for Apple Devices (5 Mbs)" which gives me a file that's just over 2Gb. Not bad, and the quality is still very good, but the file size is just too big for people to download. I get reports of people getting estimates of 77 hours to download this one file.
    I did try using the setting under Video Sharing Services / Large 540p Video Sharing just to see what it would give me, but it really wasn't that much smaller and the quality was noticeably degraded.
    I'm confused as to what to do about this. I have downloaded things from iTunes before that are good quality, about an hour and their file sizes are simply bnot this big.
    Can anyone give me some advice? Thank you. Grateful for anything you can offer.
    MC

    If you're not concerned with precise average bitrate, use h.264 codec, set bitrate to "automatic" and use the quality slider. Be sure to have "keyframes" on "automatic"; every 24 frames or so makes h.264 quite inefficient and is only useful for live-streaming, where you want people to be able to resynchronise as quickly as possible. Having multi-pass enabled might help, but I'm not sure what it does when using constant-quality encoding.
    Do a test-encoding of a representative clip of maybe about rwo minutes or so, play with the quality slider and see how far down you can go and still be satisfied with the quality. Using "automatic" bitrate uses as many bits to encode each frame as is necessary to get the required quality, and file sizes will vary depending on the type of material. Complex textures and high motion will use more bits, still frames and slow pans will use very little.
    A light chroma-channel denoising may help improve perceived quality, as may very light sharpening in case you scaled down the material.
    If you're still not happy with the bitrate vs. quality tradeoff, try reducing the resolution, but generally you should get 720p down to around 2.5 to 3.0 Mbps with adequate quality.
    On the other hand, If someone needs 77 hours to download 2 GB, they have another problem anyway. That sounds like a 56k modem connection. What's he doing trying to download HD content anyway?
    Bernd

  • How can I get to read a large file and not break it up into bits

    Hi,
    How do I read a large file and not get the file cut into bits so each has its own beginning and ending.
    like
    1.aaa
    2.aaa
    3.aaa
    4....
    10.bbb
    11.bbb
    12.bbb
    13.bbb
    if the file was read on the line 11 and I wanted to read at 3 and then read again at 10.
    how do I specify the byte in the file of the large file since the read function has a read(byteb[],index,bytes to read);
    And it will only index in the array of bytes itself.
    Thanks
    San Htat

    tjacobs01 wrote:
    Peter__Lawrey wrote:
    Try RandomAccessFile. Not only do I hate RandomAccessFiles because of their inefficiency and limited use in today's computing world, The one dominated by small devices with SSD? Or the one dominated by large database servers and b-trees?
    I would also like to hate on the name 'RandomAccessFile' almost always, there's nothing 'random' about the access. I tend to think of the tens of thousands of databases users were found to have created in local drives in one previous employer's audit. Where's the company's mission-critical software? It's in some random Access file.
    Couldn't someone have come up with a better name, like NonlinearAccessFile? I guess the same goes for RAM to...Non-linear would imply access times other than O(N), but typically not constant, whereas RAM is nominally O(1), except it is highly optimised for consecutive access, as are spinning disk files, except RAM is fast in either direction.
    [one of these things is not like the other|http://www.tbray.org/ongoing/When/200x/2008/11/20/2008-Disk-Performance#p-11] silicon disks are much better at random access than rust disks and [Machine architecture|http://video.google.com/videoplay?docid=-4714369049736584770] at about 1:40 - RAM is much worse at random access than sequential.

  • Please advice me on reading a large file

    Hi,
    I need and advice on reading a large file using JSP. I need to read a text file which contains around 2 millions records (lines). Also some times I need to find a specific line from that.
    I have to make a small web application to generate reports on the Text files after parsing those into a database (Oracle or MySQL). I have already a small similar application which based on PHP / MySQL. But still time consumption issue is there while parsing the text file into Database.
    How will it be improve if I go for Tomcat / Oracle / Java Web Component Development?
    Please advice me.
    Thanks

    Try changing your approach - don't read it into an array, process it one line at a time. Obviously any approach where you have the whole file in memory is going to exceed memory at some size of the file.

  • How do I find the file size of my presentation in keynote for iPad?

    I know this is a simple question, and I have a work around by just emailing the file to me, but I want to know how I can see the file size as I work on the file within keynote.....on the iPad.
    Thanks

    Select the album, Select all photos in the album, then click on the info button.   Number of photos and total size are on  top of info pane.

  • How can I keep the file size small when I render a .mov file to video in PS entended CS4?

    Hi,
    I haven't worked with video in Photoshop before and I am having the following issue:
    I imported a .mov file into photoshop. I trimmed the file by moving the start and finish points to the relevant points on the timeline. I then cropped the image to get rid of unwanted footage on the edge of the screen. I then selected export - render video. On the panel I chose to select only "currently selected frames" as the range and I chose "Quick Time Movie" as the file type. When I check the properties of my newly rendered movie the file size has increased by several times. The file sizes are now much too large.
    I know that I must need to alter some of the render settings but having tried altering many of the settings the result is always the same - a very large file size that is much bigger than my oringinal file.
    If anyone can let me know how I can carry out a simple crop & trim on a .mov file and end up with a smaller more compact file after rendering the video I would really appreciate it. Thanks in advance!

    Hi Marion,
    Thanks very much for your message. I have downloaded that program and it's definitely handy for examining the details of the original file. You mentioned in your message about not having to recode the file - The file I'm editing is originally from a Q3 Zoom video recorder and I can use their in-built software (handyware) to trim the file - this doesn't recode the file and so the file size just reduces by the required amount. Unfortunately there is no facility to crop the file with this software - I've looked for other software that would allow cropping without having to recode the file but I haven't found anything suitable for a simple procudure like this - do you know of any software that allows you to crop a file without recoding? Thanks.

  • Video Stalls - Larger File Size

    Just downloaded Battlestar Galactica season 2 and the video stalls at full screen. Do not have this problem with previous Battlestar Galactica shows and movies that I have downloaded in the past.
    I notice the File Size and Total Bit Rate of the new shows are three times greater in size than the shows I've downloaded in the past.
    Using the utility ativity monitor, I notice I'm maxing out my CPU when I go to full screen which I think is causing my video stall.
    I also notice that now my previous TV show downloads don't fully fill my screen like that did before the new downloads.
    I hope someone might know how I can get my TV shows back to working normal at full screen and why the new TV shows file sizes are larger than before.
    Thanks for Your Help
    Ricky
    PowerBook G4 15" LCD 1.67GHz   Mac OS X (10.3.9)  

    Thanks for the reply. Shortly after I posted, I started to relize that Apple was offering better TV Show quality which results in larger file sizes. I also went to my Energy Saver section in System Prefrences and found my Optimize Energy Settings was set for Presentations. I changed it to Highest Performance which resolved the issue.
    iTunes 7.0.2
    Quicktime 7.1.3
    RAM 512MB
    Thanks for your help.

  • Anybody know how to increase the plugin file size limit in Photoshop CS6 to greater than 250 mb?

    Can anyone tell me if it is possible to increase the plugin file size limit in Photoshop CS6 to greater than 250 mb and how to do it? Can plugins running in PSCC handle larger file sizes than CS6?

    Wow, thanks for getting back to me!!
    I am running the latest version of HDR Soft Photomatix Tone Mapping Plug-In - Version 2.2 in Photoshop CS6 on a fully loaded solid state MacBook Air. When I attempt to process files exceeding 250 mb with the plugin I get an error message and the plugin will not work. The plugin works fine with anything south of 250 mb. I have also optimized the performance settings in CS6 for large file sizes.
    The standalone version of HRD Soft’s Photomatix Pro easily processes files well in excess of 300 mb.
    I have contacted Photomatix support and they say that 250megs is simply the max file size that Photoshop will allow to run a plugin with.
    So is there any setting that I’m overlooking in Photoshop CS6 that will allow me to process these large files with the plugin? Or if there is indeed a file size limit for plugin processing in CS6 is the limit higher in CC?
    Thanks in advance for your help.

  • Saving jpeg and png files large file size

    Ive recently purchased web premium 5.5 and Im trying to save files in jpeg and png format in Photoshop and Im getting unexpectedly large file sizes, for example I save a simple logo image 246x48 which consists of only 3 basic colours and when I save it as a jpeg quality 11 it reports the file size in the finder as 61.6k, I save it as a png file and its 60.2k also I cropped the image to 190x48 and saved it as a png and the file size is actually larger at 61.9k saving as a jpeg at quality 7 the files size is a still relatively large 54k.
    I have a similar png non indexed colour logo on my mac I saved in CS3 on a pc which is actually larger at 260x148 and it's only 17k and that logo is actually more complex with a gloss effect over part of it. Whats going on and how do I fix it, It's making Photoshop useless especially when saving for the web
    Thanks

    Thanks I had considered that but all my old files are reporting the correct files sizes I have been experimenting and fireworks saves the file at png 24 at 2.6k and jpegs at 5.1k, but I don't really want to have to save the files twice once cut from the comp in photoshop and again in fireworks juggling between the two applications is a bit inconvenient even with just one file but especially when you have potentially hundreds of files to save.
    Ive also turned off icon and windows thumbnail in photoshop preferences and although this has decreased the file size they are still quite large at 27k and save for the web is better at 4k for the png and 16k for the jpeg. Is there anyway to get Fireworks file saving performance in Photoshop ? it seems strange that the compression in Photoshop would be second rate in comparison to fireworks given they are both developed by Adobe and Photoshop is Adobes primary image editing software.

  • How do I move large files from a Windows computer to my MacBook Pro? There are a lot of photos (tiffs

    How do I move large files from a Windows computer to my MacBook Pro? There are a lot of photos (tiffs, jpgs, some photoshopped files), iTunes library, word docs. Is there a particular type of external hard drive that can be used or am I limited to copying stuff onto z-drive and moving that way?

    If both computers are on the same network, you can share the files from the Windows host using SMB and mount the share on the Mac. Otherwise, the Mac should be able to read (not necessarily write) any storage device formatted in Windows.

  • How can I delete large files on my MacBook Pro?

    How can I delete large files on my MacBook Pro? Also my Emails wont delete, how can I delete them?

    Which email client are you using & which version?   Your emails are not appearing in the email trashcan? 

  • HT4863 How can I increase the file size limit for outgoing mail. I need to send a file that is 50MB?

    How can I increase the file size limit for outgoing mail. I need to send a file that is 50MB?

    You can't change it, and I suspect few email providers would allow a file that big.  Consider uploading it to a service like Dropbox, then email the link allowing the recipient to download it.

Maybe you are looking for