Hard one for me anyway!

Hi all, I would like to create a byte type which is 256bytes in size compressed.
How can I fill up a byte type with compressed data? I can use a compress file and read it
into the byte either. I need to create random data and compress it.
byte test[];
test new byte[256000];
Any ideas?
ive found this on the net but i cant make much sense of it.
Is whats below on the right track what I need?
byte[] input = "some some bytes to compress".getBytes();
// Create the compressor with highest level of compression
Deflater compressor = new Deflater();
compressor.setLevel(Deflater.BEST_COMPRESSION);
// Give the compressor the data to compress
compressor.setInput(input);
compressor.finish();
// Create an expandable byte array to hold the compressed data.
// You cannot use an array that's the same size as the orginal because
// there is no guarantee that the compressed data will be smaller than
// the uncompressed data.
ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
// Compress the data
byte[] buf = new byte[1024];
while (!compressor.finished()) {
int count = compressor.deflate(buf);
bos.write(buf, 0, count);
try {
bos.close();
} catch (IOException e) {
// Get the compressed data
byte[] compressedData = bos.toByteArray();

from your description of your problem, I'd think you would make the buffer/byte object and then fill it with data output from an object that compresses your test file.
If this is a school assignment, it sounds like the teacher just wants you to see the benefits of compressing your data.

Similar Messages

  • How can I use one external hard drive for both Time Machine and iPhoto Library?

    I have been using a 1 TG LaCie external hard drive for Time Machine backups.  My (older) Mac has 160 GB and is almost full.  I would like to move my iPhoto Library to the external hard drive, but I've heard Time Machine doesn't share one space well.  Should I
    1.  create another partition (but will this erase what I've already saved) with Disk Utility?  *I am running Snow Leopard*
    2.  create another volume to use for iPhoto, and if so, should the two volumes be of equal size?
    3.  leave it with one partition and move the iPhoto Library to the same partition with Time Machine back ups?
    I know I don't need the entire 1 TG for back up of 160 GBs.  Please advise the best path to take.  Thank you!

    You are getting incorrect information from your ASP. If you look at drive specifications the heat generated is no different for high vs low capacity drives.
    I have upgraded the internal drive in my iMac 2007 with a 3TB Hitachi drive without any heat issues or other problems.
    Larger hard drives have higher density platters so to access any given amount data the drives travel a shorter distance. Higher capacity drives should therefore run cooler than lower density drives because the drive spends less time spinning to access data.

  • I need to buy an external hard drive for my MacBook Air as it is almost full. Which one should I buy?

    Do I need to buy an Apple external Hard Drive for my MacBook Air?

    There is no such thing as an Apple hard drive, ...Apples doesnt make same.
    avoid western digital if possible. 
    Yes, having an external HD is necessary for data backups and keeping large media files for packing around etc.
    you need data redundancy.
    best options for the price, and high quality HD:
    Quality 1TB drives are $50 per TB on 3.5" or  $65 per TB on 2.5"
    Perfect 1TB for $68
    http://www.amazon.com/Toshiba-Canvio-Portable-Hard-Drive/dp/B005J7YA3W/ref=sr_1_ 1?ie=UTF8&qid=1379452568&sr=8-1&keywords=1tb+toshiba
    Nice 500gig for $50. ultraslim perfect for use with a notebook
    http://www.amazon.com/Toshiba-Canvio-Portable-External-Drive/dp/B009F1CXI2/ref=s r_1_1?s=electronics&ie=UTF8&qid=1377642728&sr=1-1&keywords=toshiba+slim+500gb
    Best small HD for the money:
    2.5" USB portable High quality BEST FOR THE COST, Toshiba "tiny giant" 2TB drive (have several of them, LOT of storage in a SMALL package)    $117
    http://www.amazon.com/Toshiba-Canvio-Connect-Portable-HDTC720XK3C1/dp/B00CGUMS48 /ref=sr_1_4?s=electronics&ie=UTF8&qid=1379182740&sr=1-4&keywords=2tb+toshiba
    *This one is the BEST portable  external HD available that money can buy:
    HGST Touro Mobile 1TB USB 3.0 External Hard Drive $88
    http://www.amazon.com/HGST-Mobile-Portable-External-0S03559/dp/B009GE6JI8/ref=sr _1_1?ie=UTF8&qid=1383238934&sr=8-1&keywords=HGST+Touro+Mobile+Pro+1TB+USB+3.0+7 2 00+RPM
    Most storage experts agree on the Hitachi 2.5"
    Hitachi is the winner in hard drive reliability survey:
    Hitachi manufacturers the safest and most reliable hard drives, according to the Storelab study. Of the hundreds of Hitachi hard drives received, not a single one had failed due to manufacturing or design errors. Adding the highest average lifespans and the best relationship between failures and market share, Hitachi can be regarded as the winner.

  • Is it possible to use more than one external hard drive for Time Machine backups?

    I want to use two hard drives for Time Machine backups.
    Bigger one keep at home and be sure it is safe.
    Second one (very small pocket size) keep with me for travels.
    I want to backup to both drives to be sure I can restore everywhere and to be sure if something bad happened with my small travel disk I can restore from home backup.
    Is there any problem with listed schema? Is it normal for Time Machine to handle backups for different drivers and keep everything consistent and smooth?

    I really need some help!  I have been using an Iomega NAS 1TB HD for the past year.  And I received an error message.  I believe I have ran out of memory on this drive.
    Then recently in the last couple of months I got a ReadyNAS Duo 2TB with 2TB RAID.  Should I switch my back ups to this one and delete the other back up file or keep the old back up image file on the Iomega?
    Can I transfer the old image back up to this new ReadyNAS? How do I do this?
    I appreciate any help.

  • Can I set up multiple usb hard drives- one for time machine and a second for media? Can one also print wirelessly with an old HP C6280 printer?

    Can I set up multiple usb hard drives- one for time machine and a second for media?
    Can one also print wirelessly with an old HP C6280 printer?

    Can I set up multiple usb hard drives- one for time machine and a second for media?
    Yes.
    Can one also print wirelessly with an old HP C6280 printer?
    Possibly by using an Airport Express, but depends on what type of port connection the printer requires.

  • Can I use one hard drive for two computers?  Newbie here.

    Newbie here.
    I currently use Time Machine for my iMac (Intel)
    I've been using my Macbook Pro (Intel) a lot lately and would like to back it up from time to time as well.
    Can I simply attach the external hard drive to my Macbook Pro and set up Time Machine?
    Can use the external hard drive for both machines?
    Will Time Machine recognized that my Macbook Pro is a separate computer and set up a separate folder on the external hard drive automatically?
    Thanks

    Hi,
    you can use the drive for as many Macs as you like, just make sure it's big enough. Time Machine will create separate folders for your Macs and will "know" which one you're using.
    Björn

  • One Format External Hard Drive for Your Mac and PC...

    I have Formatted my External HD Passport 500GB = (465.8) and split it in two partition Mac OS Extended (Journal = 232GB) and FAT32 (Ms-Dos-FAT = 232GB) and reformat to NTFS using Windows...
    How to use one External HUD for your Mac and PC you have a PC and how to have two Partition in Mac OS Extended (Journal) and FAT (Ms-Dos-FAT)as you desire the size of your partition under application, Utilities and Disk Utility and covert the (FAT32) to (NTFS)using Windows Control Panel or just search by Start, search Computer Management or just right my Computer and format the second partition to (NTFS)
    Tips for Mac OS Extended (Journaled) FAT32 vs NTFS, what works and don't work...
    (1)Mac OS Extended (Journaled) Partition can't be use in Windows to transfer files but NTFS Partition can be use in Mac by transferring file from Windows to Mac and NTFS support for files over 4G in size...
    (2)FAT32 can be use in Mac and Windows but with a limitation that a file cannot be transferred to a FAT32 partition if the file is larger than 4GB such as a video file and FAT32 file system performs more slowly than NTFS...
    (2)Mac OS Extended (Journaled) can be use in Windows when you Reformat your HD to HFS+ by third-party app such as http://www.macdrive.com/ MacDrive for $50.or http://www.paragon-software.com/home/ntfs-mac/ NTFS For Mac 6.0 for $30...
    Reference link 1 External Hard Drive for Your Mac and PC...
    http://www.myfirstmac.com/index.php/mac/articles/1-external-hard-drive-for-your- mac-and-pc
    Best regards...
    JamesUFOs...
    http://www.youtube.com/user/JamesEBEs

    I have many external drives I use between my MacBook Pro and my Windows PC's. I use a free NTFS driver for Mac OS-X to give me full read/write access to any NTFS formatted partitions when running Mac OS. I also use MediaFour's MacDrive v8 on some of my Windows PC's to access any HFS+ formatted partitions.
    Most of my drives are formatted NTFS because I have more Windows machines than I have MacDrive licenses, and with the driver for Mac OS, they are fully accessible. I have a few drives I do keep formatted as HFS+ because I have encountered an app or two that don't work quite right when they don't get to write to files on an HFS+ partition (one of my backup programs is picky about this).
    As said before, FAT32 is fully accessible between the two OS'es but it also has it's own limitations.

  • OS is Mountain Lion, upgraded no problems, used an external Hard drive for my time machine, now my iPhoto will not show any of my photo's or ay new ones I import! Help please!!

    OS is Mountain Lion, upgraded no problems, used an external Hard drive for my time machine, now my iPhoto will not show any of my photo's or ay new ones I import! Help please!!

    Do you get this window when you hold down the Command+Option keys and launch iPhoto?
    If not then you're not holding down both keys long enough.
    OT

  • HT1689 I tunes store double charged me for two songs, how do i get them to reverse the double charges off my account? also one song wong load on my iphone but i got charged for it anyway?

    Help
    I-Tunes Store double charged my account for two songs i downloaded on my phone,
    also a song i ordered wont load to my phone but i got charged for it anyway? how do i get ahold of Itunes store to reverse these charges off my account?
    Help
    Raider girl

    Connect the device to the computer.
    In iTunes, select the content desired to sync.
    Sync.
    This is all described in the User's Guide, reading it may be a good place to start.

  • Trying to find a Hard case for my MB466LL/A Macbook anyone know where I would find one. Also is this the only model number for this Macbook? Is there another Model number that the case would fit?

    PLEASE HELP!!
    Trying to find a hard case for my Macbook (MB466LL/A). I cant find anything on the Web? Is there another model number that would fit mine? Any help would be great.

    These are the specs for your computer:
    http://support.apple.com/kb/sp500
    Amazon has a number of products listed. The key is to specify a 13 inch Macbook, not the model number,

  • Choosing an external hard drive for back up

    This is more for general advice than a specific question. Right now I have my hard drive partitioned and use the second as a backup with Time Machine. It will work for most situations but not all, such as a home fire or break-in (all my photos and music, lost forever!).
    What I want to do is buy an external hard drive for backup and keep it at work. I would then bring it home every few weeks to update, but otherwise not store it in the same place as my computer. That way I would never lose more than a few weeks worth of stuff. So, a few questions, the nature of which will let you know how much of a novice I am at this.
    1) Right now, Time Machine automatically updates once per hour. When I am using the external drive will I be able to set Time Machine up to only update my back up files when I connect the external drive. Is this difficult.
    2) Any suggestions on what kind of external hard drive I should buy, or what features I should look for would be appreciated. I live in a remote area, so something I can get from futureshop.ca would be preferable.
    3) My hard drive is about 280 GB. What size should I buy.
    Advice on any of the above would be appreciated. Also feel free to toss in anything else you think I should know or consider.
    Rgds
    PF

    Snowfog wrote:
    This is more for general advice than a specific question. Right now I have my hard drive partitioned and use the second as a backup with Time Machine. It will work for most situations but not all, such as a home fire or break-in (all my photos and music, lost forever!).
    What I want to do is buy an external hard drive for backup and keep it at work. I would then bring it home every few weeks to update, but otherwise not store it in the same place as my computer. That way I would never lose more than a few weeks worth of stuff. So, a few questions, the nature of which will let you know how much of a novice I am at this.
    1) Right now, Time Machine automatically updates once per hour. When I am using the external drive will I be able to set Time Machine up to only update my back up files when I connect the external drive.
    This is what I am currently doing among 3 different backup disks (1 Time Capsule, a WD500GB, and a Lacie 160GB). You won't have to "set" anything up other than attach the new drive and select it in the TM prefs. Then when your done, reselect your normal TM disk.
    2) Any suggestions on what kind of external hard drive I should buy, or what features I should look for would be appreciated. I live in a remote area, so something I can get from futureshop.ca would be preferable.
    Most any drive will do, as you partition it correctly to begin with.
    *_How Should a Time Machine Hard Disk be Prepared?_*
    For Time Machine to work properly, the hard disk must be formatted “Mac OS Extended (Journaled)” and its’ Partition Scheme should be either GUID or Apple Partition Map.
    Time Machine is incompatible with disks partitioned as Master Boot Record (MBR). Unfortunately, this describes nearly every hard drive you can buy because MBR is a Windows partition scheme. (Naturally, this DOES NOT apply to Apples’ Time Capsule.)
    For some, Time Machine begins to perform as expected with a new external hard disk. But then the initial full backup or subsequent incremental backups fail. The user only later discovers the hard disk was still partitioned as Master Boot Record (MBR).
    One article on Time Machine made this observation: “Virtually everybody will have to open Disk Utility and repartition the disk as APM or GUID. It doesn't really matter which one because the Time Machine disk will not be bootable anyway. APM allows a disk to boot a PowerPC, GUID allows the disk to boot an Intel processor but both are easily digestible by Time Machine on either kind of processor.” [http://www.girr.org/mac_stuff/backups.html]
    It’s been recommended by many here that your reserve +at least+ double the size of your primary hard disk, that way Time Machine backups have room to grow as the size of your data grows. Additionally, the more space you give Time Machine the more history it can preserve. The less space you reserve for Time Machine the sooner older backups & deleted items will disappear.
    One poster recommended this regarding multiple partitions: “If you do create multiple partitions (half and half would be a good place to start), make sure you use the first partition for Time Machine, and the second for your own stuff (the first one will be on top in the graphical representation shown in Disk Utility; you'll understand when you see the partition tab). This way, you can expand the Time Machine volume at any later time by deleting the second partition. Disk Utility allows this dynamic re-sizing of volumes, but volumes can only be expanded toward the end of the drive, when a volume that comes after is deleted to create the room.” [http://discussions.apple.com/thread.jspa?threadID=1712437&tstart=0]
    Procedure
    Connect the hard disk you wish to use for Time Machine backups.
    Launch Disk Utility.
    It will appear twice in the pane on the left. (Make sure you recognize that it is different from the 2 icons that represent your Macs' internal drive.) The upper entry represent the device as a whole, including the controller inside. The lower entry represents the hard disk contained within the device.
    Click on the upper icon of the external hard disk.
    Select the "Partition" tab.
    For "Volume Scheme" choose "1 partition". (Choose 2 partitions if you intend on storing other data on the disk besides your Time Machine backups. Ensure that the two partitions have different names.)
    Name the disk.
    Format should be "Mac OS Extended (Journaled)".
    Click "Options".
    Select either GUID or Apple Partition Map. (See above for significance)
    Click "OK".
    Click "Apply". Then click “Partition”.
    Once the external hard disk is repartitioned, select it again in Time Machine preferences and use it for your backups. If you chose to create 2 partitions, then select the first partition for Time Machine backups, and the second for additional files/folders.
    3) My hard drive is about 280 GB. What size should I buy.
    Any TM backup drive should be +at least+ twice as large as your Macs internal hard disk.
    Let us know if this resolves your issue.
    Cheers!

  • Hard drives for Logic Pro 8, Final Cut, After Effects, etc.

    Hello gang, although i have read through many threads re: hard drive configs for different people's uses on many different forums (thats why i am here to get it straight from the apple's mouth) that i frequent and contribute to I have read everything from '10k drives only give a slight speed to boot up times' to 'with these 10k drives my machine is FLYING/___sbsstatic___/migration-images/migration-img-not-avail.png'. The ladder posted by a crazy i am sure . So, If i were to purchase 2 10k drives (raptors are my only choice?) and use one for osx and my programs and the other for my scratch disk would i then use the stock 250 seagate that came with the machine as my itunes, pictures drive (i have an external FW800 750 seagate for back ups)? If i were to do this sort of configuration what would be my benefits if any at all? I had posted this in another forum and it pretty much had me more confused as people were going back and forth as to their PERSONAL preferences and it ran the gamut . I was hoping someone that uses the programs in the subject line or know what the new drives would do to make workflow more efficient. THIS IS THE LONGEST POST EVER. Anyway, any help would be greatly appreciated. This is my 1st Mac Pro so i would like to set this lovely lady up correctly. Again, thank you for making it this far if you have .
    Best,
    Pandasarus

    Yes, the latest 300GB VelociRaptor is still king, and one G5 owner (not Mac Pro) installed three and was very pleased.
    http://www.barefeats.com/hard103.html
    There are other options.
    A WD Caviar 640GB would do fine.
    http://www.barefeats.com/harper14.html
    RAID configurations of SAS vs SATA:
    http://www.barefeats.com/harper13.html
    TB drives: http://www.barefeats.com/hard94.html
    Boot drive (doesn't have every model):
    http://www.barefeats.com/harper9.html
    I would go with 3 drives.
    Backups: always have two or more so one is safe and off-line, things happen. TimeMachine plus SuperDuper backup clones combination.
    Boot drive with just OS and applications, media drive, editing, and so you want to have a stripped scratch RAID.

  • External hard drive for video editing

    I am looking for a reliable and fast external hard drive, which I can store my projects in and work off of. I use Final Cut Pro. PowerBook G4 17"
    I don't know if my mac has the eSATA or FW 800.
    Here are what I’ve been looking at so far:
    500GB OWC Mercury Elite-AL Pro 'Quad Interface' 7200RPM 16MB Cache Solution with eSATA/FW800/FW400/USB2. Intech HD Speedtools, Prosoft Data Backup, and connecting cables for eSATA/FW800/FW400/USB2 Included. 2 year OWC Solution Warranty. (OWCMEAQ7500GB16) $217.99
    1.0TB OWC Mercury Elite-AL PRO 800 RAID Dual SATA Drive 7200RPM FireWire 800/400+USB2.0 Oxford 924 Storage Solution w/32MB Data Buffer(16MB per HD). All Cables Included, Prosoft Data Backup 3, NovaBACKUP, and Intech Speed Tools Included. 2yr Warranty. (OWCME8SRS10TB32) $359.99
    http://eshop.macsales.com/item/Other%20World%20Computing/MEAQ7500GB16/
    G-Tech G-DRIVE 500GB FW400/USB 2.0 Hard Drive $249.95
    Two year Warranty with USB 2.0 cable and Manual on CD-ROM
    Should I get the ones including the eSATA? Would this help with the rendering or playback issues? (Considering I might have to get a eSATA-to-SATA bracket/cable-adapter, since I can’t see any eSATA on my laptop.)
    The OWCs are cheaper than G-Technology and offer backup software. what would I lose if I go with OWC? or if u have better suggestions?
    Is there any auto back up program for mac?
    I am also having difficulty rendering my files specially the ones with more than 2 layers of images. I thought it might have been because of the USB connection. Beside upgrading the connection with the new hard drive is there any other way to enhance the working quality? or do I need any thing else?
    This is what I have on my PowerBook:
    CPU Type: PowerPC G4 (1.2)
    CPU Speed: 1.67 GHz
    Bus Speed: 167 MHz
    I included a lot of Qs but Your answers to them is truly appreciated.

    Any of the drives you mentioned would be fine but since your 17" PB has a FW800 port, I'd go for drives that support FW800. G-Tech also has them, but as you said they are higher priced.
    The ProSoft backup software that comes with the OWC drives is very nice but it really provides more convenience than anything else. You can always backup your files manually without any special software (using the Finder to copy files/folders from one drive to another ... or you can even set up Automator actions to do backups). Anyway, the ProSoft backup software is only ~$40, so you're not out much if you have to buy it separately.
    There are other good backup programs out there, SuperDuper and Retrospect come to mind; Lacie includes SilverKeeper and/or Retrospect Express with their drives. And Leopard (OSX 10.5) includes Time Machine, which is an auto backup capability. Requires its own hard drive for backup, by the way.
    As for eSATA, you would have to get an eSATA card for the PC Card/Cardbus slot in your PB. eSATA is even faster than FW800 but I think in the case of a G4 PB it's probably overkill.
    You mentioned problems rendering files ... if you are currently using a USB external hard drive, that is most certainly the problem. USB 2.0 can't keep up with the demands of video and your PB only has the slower USB 1.1.

  • Where could I buy a new hard disk for my macbook pro 15''(MB986CH/A)

    Does anyone know where I could buy a new hard disk for my macbook pro 15''(MB986CH/A) (mid 2009)? The hard drives sold in Apple Store are not for macbook pro... Thanks a lot!

    At one time Apple use to put an Apple firmware on the drives installed into Mac computer. That is not the case anymore. And even if they did that firmware was just to indentify the drive as an Apple drive. Those same drives would work in any computer and any drive would work in a Mac computer. Same is true today. There are NO Apple Mac drives. Apple uses the exact same drives as any other computer.
    Apple uses the exact same hardware as all other computers. Same CPU, GPU, RAM, Drives, DVD drives you name it, it is the same as any PC.
    Good Luck but just because you go to a Mac-centric store doesn't mean it is any different then what you would buy some place else, other then it may cost more from one of those Mac-centric places.
    Joan_hk wrote:
    Thanks. According to my previous experience with an old white macbook, there might exist some compatibility problems for the hardware I bought from computer parts store...That's why I want to find an official retail store or reseller.... Thanks anyway!

  • HT201250 if I used external hard disk for backup time machine, is it possible to use that external hard disk to save another else from diffrent computers?

    If I used external hard disk for back up time machine, is it possible to use that external hard disk to save another else from diffrent computers?

    Welcome to Apple Support Communities
    You can do this, but you should make a new volume on your external disk. Time Machine needs a volume that is only used to store backups, so you can't store other data in the same volume as the one you are using for making backups.
    If you want to create another volume on your external disk, use Disk Utility to do this > http://pondini.org/OSX/DU3.html Anyway, you should get another external disk to store other files, but if you don't want to, you can create another volume in it

Maybe you are looking for

  • How do I get back to my basic start page from any ...

    How do I get back to my basic start page from any other page? There should be a one click link but I can't see how to do it. Apologies for illiteracy. Like say from this help page, how can I get back on skype and make a call?

  • How to remove trailing spaces in SQL PLUS spool

    Hi, I've requirement to pull data from tables and I'm using sqlplus spool to automate data fetch from various tables: I'm using the following script for the same : set echo off set feedback off set pagesize 0 set linesize 2000 set heading on set trim

  • CD/DVD Optical Drive - Portege Laptop R700-S1310 - Need help.

    Recently, my Portege R700S1310 has given me problems regarding it's DVD/CD RW drive.  I wanted to change it out, and did all the screw removals, etc.  Once I removed the screws, I tried to remove the drive and pulled it out of the location.  Unfortun

  • Are you able to buy playlists for other people?

    I've been trying to gift one of my playlists to a friend but I keep getting an error message that the store is not working. It's been that way for 24 hours. Anyone else having this problem? Any ideas what the deal is?

  • Trace the updates on a Bex query

    Hi Team, Recently One of our Bex query got updated with new CKF & RKF by one of developer. But i don't know what are the changes that he made to that query. How can i get the total changes made by him and on what date he made this changes and what wa