How can I get String from Bytes

I want to get String from array of bytes but i have some trouble from byte that it's lager more than 128. How can I do ???
Please hepl me. Thanks very much.

This program is only to show you what the relationships are between unsigned byte, signed byte, character, and binary values. Because of the constraints that Java has, the program code is not especially clean. Run the program and see if it helps. As has been said, the character output is dependent on the encoding in use.
Here is a sample of some of its output:
Unsigned byte= 189 Signed byte= -67 Character= � Binary= 10111101
Unsigned byte= 190 Signed byte= -66 Character= � Binary= 10111110
Unsigned byte= 191 Signed byte= -65 Character= � Binary= 10111111
Unsigned byte= 192 Signed byte= -64 Character= � Binary= 11000000
Unsigned byte= 244 Signed byte= -12 Character= � Binary= 11110100
Unsigned byte= 245 Signed byte= -11 Character= � Binary= 11110101
Unsigned byte= 246 Signed byte= -10 Character= � Binary= 11110110
public class ATest {
    public static void main(String[] args) {
        int in;
        byte by;
        String bin;
        char chr;
        for(in=0; in<256; in++) {
            // create a byte whose binary value is equal to the;
            // integer loop counter;
            by = (byte)in;
            // mask off sign extension [that I don't agree with!] and;
            // cast the resultant 8 bits to a char;
            chr = (char)(by & 0x00ff);
            // since there's no Byte.toInteger, must cast to int to get;
            // binary string and then delete unwanted portion of string;
            if(in<128) {
                bin = Integer.toBinaryString((int)by);
            } else {
                bin = Integer.toBinaryString((int)by).substring(24);
            // print everything;
            System.out.println(
                "Unsigned byte= "+in+
                " Signed byte= "+by+
                " Character= "+chr+
                " Binary= "+bin);
}

Similar Messages

  • How can I get values from listbox?

    Hi all,
    I need to get price values from Price List (Inventory -> Item Master Data screen). It's important to get values from field 'Price' BEFORE item will be added/updated.
    How can I get values from Pricelist listbox?
    Thanks for any suggestions or short sample code.
    Best regards,
    Andy

    Hi Andy
    Here is som sample code that will get the description of the price list and also the price that is displaying at the time. The item master must be open for this snippet of code
      Public Sub GetItemPriceFromOpenWindow()
            'this is assuming item master is open
            Dim oEdit As SAPbouiCOM.EditText
            oEdit = SBO_Application.Forms.GetForm("150", 1).Items.Item("34").Specific
            SBO_Application.MessageBox(oEdit.Value)
            Dim oCmb As SAPbouiCOM.ComboBox
            oCmb = SBO_Application.Forms.GetForm("150", 1).Items.Item("24").Specific
            SBO_Application.MessageBox(oCmb.Selected.Description)
        End Sub
    Hope it helps

  • HT203167 lost my hard drive how can i get songs from ipod back to new computer

    I lost my hard drive and want to get my music back on my new computer. How can I get songs from my ipod to my computer? I am afraid to sync it and losing what is on my ipod. Any help would be appreciated.

    It has always been very basic to always maintain a backup copy of your computer for this very occasion.
    Use your backup copy to put everything back.
    If for some reason you have failed to maintain a backup, not good, then you can transfer itunes purchases from your ipod:  File>Transfer Purchases

  • How can I get Data from the Sound cart in Labview? Does a VI exist?

    How can I get Data from the Sound cart in Labview? Does a VI exist?

    Yes, there are VIs for acquiring data from Sound cards. And examples too. If you don't have LabVIEW yet, do a search on NI's site for example VIs.
    Khalid

  • How can i get contacts from my old Nokia phone to iphone 4S

    how can i get contacts from my old Nokia phone to iphone 4S?

    Appreciate the reply thank you
    Issue being is I don't have the lead for the samsung any longer but have the memory card?
    An yes I know I need to get them onto my MAC but how is what i'm struggling with?
    Any help would be appreciated.
    Many thanks

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • How can I get music from old mac to new mac?

    How can I get music from old mac to new mac please?
    Can't seem to make Migration Assistant work. Doesn't ask about or transfer files.

    I just migrated into a new MBP from an old one.
    It did not bring the music over.  Apple's instructions are to use the Home Sharing feature of iTunes.
    Open iTunes on your old Mac.  Select Home Sharing under the Advanced menu.  Sign in.  Do the same on your new computer.  Then when the library appears under Home Sharing on the left-hand panel on your new computer's iTunes, you can select all and Add To Library.
    That's what Apple says, anyway.

  • How can I get sound from tv or stereo when watching netflix on MacBook Air?

    I have my macbook air hooked up to my tv and want to watch netflix but the only sound is from my macbook.  How can I get sound from other sources ie tv or stereo?

    Check with Netflix for their system requirements.

  • How can i get data from a maintance view?

    Hi all.
        Can you give me some suggestion about 'How can i get data from a maintance view?'?
         Thanks
         Best regard

    hi
    good
    go through this link
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ecdf446011d189700000e8322d00/content.htm
    thanks
    mrutyun^

  • How can you get pics from your Camera roll to you photo stream

    How can you get pics from your Camera roll to you photo stream

    iCloud: Photo Stream FAQ
    iCloud: Photo Stream
    iCloud: Set up Photo Stream

  • How can i get input from user in Workflows

    Hello professionals,
    I'm new to SAP B1 Workflow, i have created some workflows and they all worked fine.
    But, I am wondering, How can i get input from user?. For example, i want to display list of options to choose between them and route the workflow based on the selected option. I don't want to use the exclusive gateway and check for some conditions, i want to get input from user.
    How can i do that?
    Thanks in advance,
    Kareem Naguib

    Hi,
    Please refer SAP help file:
    http://help.sap.com/saphelp_sbo900/helpdata/en/b8/1f9a1197214254b79bcf8f93f9fff9/content.htm?frameset=/en/44/c4c1cd7ca22…
    Thanks & Regards,
    Nagarajan

  • I purchased a song (Awaara Hoon (instrumental)) from itune store but it gives me a non-protected m4a file. I need a protected m4p file. How can i get it from itune store??? thanks in advance

    I purchased a song (Awaara Hoon (instrumental)) from itune store but it gives me a non-protected m4a file 
    I need a protected m4p file.
    How can i get it from itune store???
    thanks in advance

    All the music from iTunes Store aren't protected. You can search the web for a site that sells protected music.

  • HT201302 Hi People! please help...I want to know how can i get photos from ipad to the computer, that were synchronized previously to ipad but from another pc that i dont have access anymore and these pics are now only found in this ipad and no other plac

    Hi People!
    Please help...I want to know how can i get photos from ipad to the computer, that were synchronized previously to ipad but from another pc that i dont have access anymore and these pics are now only found in this ipad and no other place.

    Hi Alan,
    Thanks for the help, but i've actually done that before.
    It does not help, because it only shows the photos on the camera roll and do not show the photos synchronized with that pc that i dont have access anymore.
    The photos/albums all appear on the ipad, i can see it without problems but i cant get them out of the ipad to save onto pc for backup.
    And i reaaly need it, as it is the only place that i actually have these photos now...

  • How can I get path from af: inputFile or a uploadedFile

    Hi, there,
    I am getting error messages while sending attachment.
    I firstly tired getting the attachment from <af:inputFile> and attach it to the email. It failed. Then I put the file name directly into my code, still choose the same file from the <af:inputFile>, it failed again. However, from the code you can see, I can get system out println to print the file name, even the file content.
    I realized that I might need the file path, but I don't konw how I do get the path, should I write code in the backing bean of uploadedFile or in the send() in the Application Module ? How can I get the path?
    any advice is welcome and thank you very much!
    The system.out.println result is
    08/05/09 11:56:38 2javax.activation.FileDataSource@1674b36
    08/05/09 11:56:38 2.1 jkljlj
    08/05/09 11:56:38 2.2New Text Document.txt
    But the error message still says :
    nested exception is:
    class javax.mail.MessagingException: IOException while sending message;
    nested exception is:
    java.io.FileNotFoundException: New Text Document.txt (The system cannot find the file specified)
    Here is my code:
    ViewObject issueView = getIssueView1();
    Row x = issueView.getCurrentRow();
    String fileName = "New Text Document.txt";
    System.out.println("1 " + fileName);
    System.out.println("1.5 " + x.getAttribute("attachmentName"));
    // msg.setText(body);
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText(body);
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    // String attachmentName = (String)x.getAttribute("attachmentName");
    //if (attachmentName != null) {
    MimeBodyPart mbp2 = new MimeBodyPart();
    DataSource source = new FileDataSource(fileName);
    System.out.println("2" + source);
    System.out.println("2.1 " + x.getAttribute("attachment"));
    mbp2.setDataHandler(new DataHandler(source));
    //mbp2.setFileName(source.getName());
    mbp2.setFileName(fileName);
    System.out.println("2.2" + fileName);
    mp.addBodyPart(mbp2);
    msg.setContent(mp);
    // send the message!
    getDBTransaction().commit();
    Transport.send(msg);
    System.out.println("\nMail was sent successfully.");
    } catch (Exception e) {
    System.out.println("Error: " + e.getMessage());
    }

    I wish you and others like you would say what you are trying to do, not how you are trying to do it. That would save those who would like to help the trouble of figuring it out. However, I'm going to make a guess at what you are doing. Tell me if I'm right.
    You are writing a page that lets a user construct an e-mail message. I assume that the page has fields like: addressee, subject, and message. It also has a field, defined as an <af:inputFile> component for getting a file to be added as an attachment to the e-mail.
    You will want to look at forum posts and tutorials about how to upload a file. You will see that the "value" attribute of an <af:inputFile> will normally contain EL referencing a property of a backing bean which has the UploadedFile class. This class has methods for getting the filename, MIME content type, and an InputStream containing the data in the uploaded file. These pieces of information are all you need to add an attachment to an e-mail. You don't need the file's path, which is a good thing, since that information is not available to you.
    I've never used Javamail, so I can't tell you exactly how to use it, but I do understand the basics of sending e-mail. What you are going to do is create a multi-part message. The first part will be the message itself. Subsequent parts are the attachments. Each attachment can have it's filename and MIME content type set. Then you read the file through it's InputStream and write it to the message content. If the file contains binary data, you will need to pass it through a filter that will encode it to the Base64 format - which represents your data as 7 bit bytes.
    You will NOT be using the database connection or anything from the data controls to send an e-mail, unless you also need to save a copy to the database. The connection that is needed for e-mail is a connection to an SMTP service. Ask your e-mail administrator for some help with this.
    You MIGHT want to write most of this code in your Model project as a business component. Then your backing bean would probably just pass the fields as parameters.

  • How can I get songs (from CDs) on my Nano onto my laptop?  Do I have to rip all the CD's again just becasue I'm using a different computer?

    How can I get all my songs (from CDs) onto my laptop from my Nano?
    Do I have to rip all those CDs again even though they are on the Nano?
    I thought I was allowed to have multiple PCs and use the sync feature.  Yet when I plug in the Nano the message says it will sync to what's on my laptop which are only a few songs I've purchased!!
    I thought Apple was better than that?!  And to think I was going to purchase an iPad!  But if I can't synch my music to other devices, why bother.
    In order to get my music to iCloud via iMatch, I guess I have to rip them all again!  What a pain in the butt...:(

    See Recover your iTunes library from your iPod or iOS device.
    tt2

Maybe you are looking for

  • Windows 8.1 slow screen refresh

    What could be wrong with my Windows 8.1. Everything is noticeably laggy and slow when browsing web pages and using normal apps like file explorer. It feels like I'm using this computer via somekind of a remote connection. I have Windows 8.1 x64 insta

  • How to reload sound modules?

    I'm using alsa + pulse sound system. I also have Openbox as a stand-alone WM and lightDM,  but the same thing occurs on my debian testing + gnome. I've been trying to solve this issue for several days but with no success. Below is the output from als

  • PI WS Adapter not working

    We are are trying to perform an IDOC to web service integration. I have tested the service using the SOAP adapter and it works however we are required to use the WS adapter which we cannot get to work. We have also tested the web service enpoint with

  • Service Request with Object Reference filled-out automatically

    Hi CRM experts, I'm trying to understand how is possible (if exist a customizing way) to filled-out automatically the Reference Object of the Service Request. Process steps: First, I have to search for the Ibase component and confirm it; then I have

  • Model sb0400 not sta

    Ok First i apologize for my earlier rant. now i have tried several differnt things, and all that seems to work well is if i dont do anything else with my computer but play music. not really acceptable. it appears from reading this board that there is