Problem with number of bits........

Hello every one here........
I have a problem while converting a string of bits into characters...........my method is something like this......I am giving a string on client side....converting that string into string of bits and sending the bits to server side....now my problem is how to convert this string of bits into string which i originally gave at client side......
I used a method as shown below:
while(str.length()>0)
          i=7;
          System.out.print((char)Integer.parseInt(str.substring(0,i),2));
          str=str.substring(i);
here "str" is the string of bits which i received from client.......now coming to original problemEach character in the string which i gave on client side are converted to string of bits having 7 bits except the "space character" which is taking only 6 bits...... in my method as i am grouping 7 characters and printing the output i am getting wrong result after "space character"........
can anyone solve my problem.....
thanks in advance....
Deepika

class BitStuff
     public static void main(String args[])
          try{
          String str=JOptionPane.showInputDialog("Enter ur code");
          char ch[]=str.toCharArray();
          String bitString="";
          String stuffedBits[]=new String[10000];     
          String stuffedString="";
          String counts;
/*here i am ensuring dat each character generates 7 bits*/
          for(int i=0;i<ch.length;i++)
               counts=(Integer.toBinaryString(ch));
               if(counts.length()<7)
                    for(int j=counts.length();j<7;j++)     
                    counts="0".concat(counts);
               bitString=bitString.concat(counts);
          String bitsArray[]=bitString.split("11111");
          for(int i=0;i<bitsArray.length;i++)
               stuffedBits[i]="111110".concat(bitsArray[i]);
               stuffedString=stuffedString.concat(stuffedBits[i]);
          stuffedString=stuffedString.replaceFirst("111110","");
          stuffedString="01111110".concat(stuffedString);
          stuffedString=stuffedString.concat("01111110");
          System.out.println(stuffedString);
          Socket s=new Socket("localhost",8280);
          OutputStream os=s.getOutputStream();
          byte b[]=stuffedString.getBytes();
          os.write(b,0,b.length);}
          catch(Exception e)
          {System.out.println(e);}
as the ascii of space is 32 it is 100000 here the method returns as 100000 instead of 0100000......

Similar Messages

  • PROBLEM with 24/96 bit-rate USB DAC that worked fine until I plugged in two

    I'm using a late 2008 15" Macbook Pro that I bought Jan 2009 right before the SD card models came out. Mac OSX 10.6.4 and iTunes 9.2 are installed. I have a Nuforce Icon HDP and a CEntrance DACport 24/96 bit-rate USB DAC (external sound cards) that still work great right now. Note - 16 bit/44 Khz is CD quality, and these 24/96 files are hi-resolution downloads that are closer to SACD or DVD audio.
    I have been evaluating a new third 24/96 USB DAC plugged directly into the Macbook USB port (no hub) which has been working fine for over 2 weeks with 24/96 bit-rate lossless music files in iTunes. Audio Midi Setup is set for 24/96 to match the music file's resolution. After making suggestions to the manufacturer they made some improvements and sent me a new version to listen for the differences.
    I listened to the new one for a day and it worked fine, but when I plugged in the original test sample into the second USB port at the same time as the new one in order to compare them, the sound became garbled and noisy. This never happened when either one was plugged in by itself. Note, if I make changes to the DAC's bit-rate in Audio Midi Setup I usually close iTunes first and then re-open it when I am done.
    Upon hearing this new problem I unplugged both of the new USB DACs and plugged just one of them back in, but now it causes iTunes music playback to pause when one is plugged in and set for 24/96 in audio midi setup. Prior to plugging in both at the same time, either one worked just fine by itself. There is no reason when unplugging one or the other that they shouldn't start working again. But now I can't play any 24/96 music through either one anymore. In quicktime player the songs don't pause like with iTunes, but there is no sound coming through even with just one DAC plugged in at a time. Then I discovered that if I go into Audio Midi Setup application and lower the bit rate to 24/48 then iTunes will resume playing again and I can hear the music fine with iTunes or Quicktime player.
    Basically, my Macbook Pro has now lost the ability to play 24/96 bit rate with either of these new USB DACs, when they both worked fine before I plugged them in at the same time. More confusing is that they use the same USB receiver chip as in one of the DACs that I mentioned above in the first paragraph, and both the HDP and DACport still work fine at 24/96 bit-rate. It's only these two new USB DAC that require me to lower the bit rate in Audio Midi Setup to 24/48 in order to listen through them, and this wasn't a problem as recently as yesterday!
    The computer is acting like some setting needs to be wiped out - it's DEFINITELY NOT the USB DAC's that are faulty because they still both work fine at 24/96 on my wife's iMac (I'm afraid to try plugging in both at the same time to the iMac in case I screw that Mac up too).
    I have reset the PRAM a few times, and this doesn't fix the problem. I thought maybe the com.apple.audiomidisetup.plist file could be corrupted and deleted it, but that didn't help. I don't know what to try next to get the Macbook to start fresh when trying to use these devices, short of having to re-install OSX.
    Please, does anyone have a suggestion of how I can make the Macbook forget it ever saw these two USB DACs, and let me start fresh so they start working normally again? I do dozens of reviews for Head-fi.org and I can't afford to have my Macbook Pro compromised like this, which could prevent me from doing some reviews or evaluating new products.

    UPDATE:
    As noted in the first post, both of these newer USB DAC work fine at 24/96 on my wife's iMac, so it's clear that they didn't both become defective when I connected them to the Macbook Pro at the same time.
    Resetting the Macbook Pro PRAM didn't help, so I removed the hard shell laptop case to get to the battery and remove it, then reset the SMC. After that I could use the original DAC at 24/96 again, but only IF it was plugged into the rear USB port. If I plugged it into the front USB port then the sound was garbled and filled with noise. This was a vast improvement over no sound at all.
    Then I switched to the replacement/updated DAC, but I got no sound at all from either USB port at any bit-rate. And returning to the original DAC again now results in no sound again.
    Sigh... I will reset the PRAM and SMC again, and see how far I can get with this. I'd still love some help. Thanks!

  • Problem with number-fields in csv-Export-Files

    Hello,
    the export with the csv option works fine and our users like this export-function.
    But Unfortunatelly we have some problems with the exported number fields. In my region I defined the field with a format mask.
    On the screen it looks fine but when I change to csv the values are exported as text-values.
    So in excel the columns are shown with left alignment.
    When I try to change the format in excel to number, excel change the column type but not the value inside.
    On this account we cannot use the sum-function and the display of the value is wrong (alignment).
    Which possibilities do I have to resolve that problem?
    Thanks in advance
    Ulrike

    I have the same issue - Anyone any ideas on how to export currency values in a report to excel as numbers?

  • Sound problems with vista 32 bit on xfi xtremegamer

    hi im havin sound issues with my sound blaster xfi fatality xtremegamer on vista 32 bit. the sound will sound like a skippin cd or sound like it is stuterin for a few seconds than it will play fine than do it again later on. i was wounderin if its a driver issue with vista or my sound card has broke? i had it runnin on xp and had no problems. can anyone help me please as my card is only abot 8 months old so if it could be faltiy i am still covered by warrinty.

    I don't know if it's the driver that's causing a problem or if it's one of your components that's causing a problem. All I know is that the X-Fi is working great on my system, both in XP Pro and Vista Business. I'm not 100% sure about this, but I think I installed the driver first and then the software from the leaked Vista Suite that I downloaded from a link in a post on this forum. Never had a problem with any of the previous drivers either, but on the other hand this system was built in november/december last year, so the hardware was fairly new at the time.

  • Problem with "Number Generation Program'

    Can someone please help me with my Number Generation Program. I am new to java and I am at a sticking point. I want to develop a program that will do the following:
    1. Accept a set of numbers (6 numbers per set).
    2. Remove duplicate numbers.
    3. Generate unique set of numbers (6 numbers per set) using only the numbers that were originally entered.
    example: -> numbers entered: 12 33 45 51 7 10
    5 34 33 8 11 21
    5 6 13 9 10 51
    duplicate numbers removed: -> unique numbers
    12 33 45 51 7 10
    5 34 8 11 21 6
    13 9
    Final result: -> generate unique set of numbers only using the above unique 14 numbers
    5 6 7 8 9 10
    5 6 7 8 9 11
    5 6 7 8 9 12
    5 6 7 8 9 13

    I am having a problem with the following:
    1. accepting the numbers
    2. removing duplicate numbers
    3. generating the number sequence sets
    As I mentioned earlier, I am new to java. I just completed my first java class and I wanted to develop this program.

  • Problem with colors and bits

    So I have this problem, I made a drawing with my tablet in 32bit color in photoshop and I want to save it as a TIFF file, but when I save it the image that is the tiff file is black and white and the cuality is not good.I think there is some kind of problem with the RGB color.If someone can tell me how to fix this ?
    Also when I try to change the image to 16 or 8 bit(so I can save it as a JPEG file), it looses all its effect like details made with brush with low opacity.I really hope someone can help me out

    Just to be clear, 32 bit color (when used with an RGB image) is 32 bits each for red, green, and blue = 96 bits / pixel.
    The use of images carrying 32 bit color is uncommon, and this format is used primarily in editing to deal with High Dynamic Range imagery.  I suspect whatever tool you're using to view the TIFF you saved with 32 bit color is unable to deal with the format, which is why you're seeing it looking poorly and in black and white.
    Your instinct is correct to reduce the bit depth to save in a more common format.
    However, you should not be seeing a visible degradation when reducing the bit depth to 16 bits / channel.  That's still a very accurate format.  How are you "changing the image to 16 or 8 bit", specifically?
    -Noel

  • Flash player 11 problem with vista 64-bit

    Firefox browser 64-bit, I think
    OS - Vista Home Premium - 64-bit
    Adobe flash player 11 does not work with the 64-bit version of vista (it's a fact)
    Can I download a 32-bit version of FP 11 on my 64 bit version of Vista?
    Can I try loading a 32-bit version of firefox and then download the 32 bit version of FP11?
    How do I get to a 32-bit version of firefox to download it?
    How can I get to a previous version of flash player - 10.3?
    What is wrong with Adobe that they make a flash player that will not work with Vista or XP 64-bit OS?
    Most of the videos no longer play - just get a message that the video is no longer available - problem started when I downloaded FP 11

    Try using the installers from the links in http://forums.adobe.com/thread/909550
    P.S. topic moved to the Installation section of the forum.

  • Problem with number datatype dimension in BIB

    Hi,
    I've got a problem. When I create dimension with number datatype and I assign it to my cube, I cannot use my cube with my BIB presentation object - such as Crosstab. Is this possible only with varchar dimensions?

    It should work, but it would be helpful if you could specify more information, for example which errormessage you are seeing and where.

  • HT5634 Bootcamp 4 driver problems with Vista 32 bit

    Support says bootcamp 4 and Vista 32 only for my MacPro, but drivers won't install for anything but Windows 7.  Should I download bootcamp 2.0 and reinstall Vista?  Anyway to get drivers for Bootcamp 4 with Vista?

    I don't know if it's the driver that's causing a problem or if it's one of your components that's causing a problem. All I know is that the X-Fi is working great on my system, both in XP Pro and Vista Business. I'm not 100% sure about this, but I think I installed the driver first and then the software from the leaked Vista Suite that I downloaded from a link in a post on this forum. Never had a problem with any of the previous drivers either, but on the other hand this system was built in november/december last year, so the hardware was fairly new at the time.

  • ITunes not compatible with iPod Touch 4th gen (problem with Windows 64 bit)

    So I've been trying for about a month or so to sync my iPod Touch to iTunes but ever since i updated it to iTunes 11 it has been saying that i need to uninstall it and install the 64 bit version. I've done that twice this week alone and its still not working, saying again that i need the 64 bit which I already have. I've ended up completely erasing previous iTunes data to see if that would help, but that just ended up being more hassle. I don't think its just my iPod, because it refuses to sync my iPad 2 manually as well.
    Please help me, i'm at my wits end.

    You are very perceptive - has nothing to do with your ipod, has to do with your Windows. You can try couple things.
    One - reinstall itunes "apple way" and when downloading disable your anitvirus.
    http://support.apple.com/kb/HT1923
    please make sure that you completed not only step one, but also step two.
    Then disable your antivirus and go to step three.
    iTunes 11.0.5 for Windows 64 - Apple - Support
    if that does not work go to thing number two.
    Two - come back here with precise text of the message, see if anybody had it before.

  • Sync problem with itunes 64 bit

    Hi, it's impossible to sync an iPhone 4 with iTunes 10.4 64 bit (sync in one step and in only few seconds but actually it do nothing) and cannot install iTunes 32 bit on windows 7 64 bit. Never had that problem on 32 bit.
    What can I do?

    I worked though this issue today on my PC and I have it working.
    The piece that worked for me was that you have to uninstall apple components in a specific order. I also rebooted my pc after the uninstalls were complete. I found this on the apple support site (see below).
    Uninstall in the following order:
    iTunes
    QuickTime
    Apple Software Update
    Apple Mobile Device Support
    Bonjour 
    Apple Application Support (iTunes 9 or later)
    I then reinstalled 64bit Itunes by saving the package, right clicking and run as administrator.
    This reinstalled itunes then I recieved another error, iphone could not be synced 13019. I researched this and I found out that the itunes library could not find one or more of my music files in the library these are denoted by an exclamation mark. I either had to delete the files or double click on the files and click locate and then point them to the location of the missing files. After I had found all of the files it was able to sucessfully sync and all is good.
    I hope this helps...

  • Editing problems with iTunes 64-bit in Vista

    Hello!
    Just bot a new computer with Win Vista 64-bit and had to install new iTunes 64-bit.
    It's somewhat slow when switching between Windows and iTunes.
    Also, what happened to the "quick" edit feature?
    As in.... highlight song, hit F2 or just click ONCE with left mouse button and you can EDIT the song title, artist, etc...
    It's NO longer available!
    What happened to it?
    I'm RE-importing my HUGE collection of playlists and backed up library and songs, which is all MESSED up and.... I have to spend TONS of time now EDITING the title info!!!
    Anyone have problems or any solutions to this "editing" snafu????
    Thank you!

    Responding to own post.... Found answer!
    Must set permissions!
    Highlight iTunes folder..
    Right click..
    Properties..
    Securities tab...
    Click on EVERY group/user names..
    Allow..
    Full control..
    OK!
    Saved!
    Darn Windows Vista!
    Screwing up the file/folder permissions due to the hated UAC feature!

  • Problem with number field

    Hi,
    I'm using ADO (Oracle Provider for OLEDB) to connect Oracle 9. If the type of any field in table is Number(9) and I open query with this field, all negative values are displayed as positive values. For example: If I write -1 value to this field and then post the dataSet (Delphi7 - TADOQuery) value is refreshed to 1. Real value in database is -1.
    Could anybody help me with this problem?
    Regards Jan.

    Once again :)
    I finally foud out that Deplhi does support (varDecimal), but delphi TCustomADODataSet (ADO recordSet wrapper) component incorrecltly treats such field type. It regards Decimal(<9,0) as integer (TIntegerField) but when it gets value from underlying ADO recordset it expects integer variant. So it's delphi problem. I hat to fix this problem in source code of this component.
    Regards Jan.

  • MSComDlg.ICommonDialog Problem with Windows 64-bit system

    Hi all!
    I try to use the common Windows dialog box for saving files. For this I'm using the ActiveX-class "MSComDlg.ICommonDialog" with the propertynode input "Filter" for the file types. It's the standard "SaveAsType.vi" (somewhere in the forum).
    Everything works fine on a 32-bit Windows system. But when I run the code on a 64-bit system I can not save my file with the last file-extension in the box field. I always get a error-message: "The file name is invalid!" This happens only when the last box-element is selected. All other run normal.
    So for example:
    If may box array is
    Matlab Files (*.mat)|*.mat
    Text Files (*.txt)|*.txt
    Excel Files (*.xls)|*.xls
    and I select to save as *.xls and write as filename "Hello" in, I get on the 64-bit machine the error:
    "Hello
    The file name is invalid"
    When I change the order of the box array *.xls will go but the new last element will produce this error.
    So, can someone help me?
    Kind regards,
    llpauli
    P.S. I'm using Win 7 64bit with labview 9 32bit. exe tested on win7 64 bit and win xp 32 bit.

    Hi
    Im using win 7 64bit. I'm able to register the comdlg32.ocx now but can't use it in labview. There are always error messages.
    Which one do you use (see screenshots)
    Regards
    DianaS
    Attachments:
    comdlg1.gif ‏38 KB
    comdlg2.gif ‏37 KB

  • Problem with Number conversion!

    Hi all
    I am reading data from a msSQL Database. One value is a decimal format 9(10,3)(means 10 digits in total (including the ',' ; 3 decimal afer the comma)
    I am receiving for instance the value 567.200 from the DB.
    To do an RFC to a SAP System I have to convert with FormatNum to 567,200
    This works well when I am using ######.### and ',' in the FormatNum function of the mapping
    Later on, I have to convert it back to write the value into a so call history table. If I am now using ######,### and '.' in the FormatNum function I am getting every time a java exception!!
    If you suggest me to use an own java function please give me a concret code, because I am not a programmer. Only basics ;->
    Regards Oliver

    java.lang.NumberFormatException: For input string: "123,567"
    An arithmetic function requires a Java conform number.
    Regards
    Stefan

Maybe you are looking for