Simple way to turn string to hex

Hello...
I was wondering if there would be nice way to get string, rather long one I might add, to hex form for mobile phone purposes... Preferably to string if possible.
I have looked through forums and have tried to find a nice solution but can't.

To Hex String:
final String nonHexString = "Hello from YoGee";
System.out.print("0x");
for (int i = 0; i < nonHexString.length(); i++) {               
  System.out.print(Integer.toHexString(nonHexString.charAt(i)));
}Back again:
final String hexString = "0x48656c6c6f2066726f6d20596f476565";
int length = hexString.length();
String[] temp = new String[(length - 2) / 2];
int counter = 2;               
for(int i = 1; i < ((length - 2) / 2) +1; i++){
  temp[i-1]= hexString.substring(counter,counter+2);
  counter = counter + 2;
char[] chars = new char[temp.length];
for(int i = 0; i < temp.length; i++){
  chars[i] = (char) Integer.parseInt(temp, 16);
System.out.println(new String(chars));

Similar Messages

  • Is there a way to turn off and On the isight camera or app to do it ?????

    Hi
    Does anyone know either of a Simple way to Turn off the isight camera on a Macbook pro (3.1 model with Snow leopard) or a simple program or Widget to do this ??
    I have already Googled this but cannot find much - except disable certain files, or a Applescript by Techslaves.org called isight disabler , which seems great except I have to run applescript each time run this script, put in password, then select !
    SO is there a Basic app or even a Way of making the isight disabler work like a simple app - or a way to do with Mac's settings ??
    Any help is Appriciated
    Thanks Mark

    Globalmark wrote:
    Hi
    Does anyone know either of a Simple way to Turn off the isight camera on a Macbook pro (3.1 model with Snow leopard) or a simple program or Widget to do this ??
    I have already Googled this but cannot find much - except disable certain files, or a Applescript by Techslaves.org called isight disabler , which seems great except I have to run applescript each time run this script, put in password, then select !
    SO is there a Basic app or even a Way of making the isight disabler work like a simple app - or a way to do with Mac's settings ??
    Any help is Appriciated
    Thanks Mark
    Barring some unusual circumstance, there should be no need to disable your built-in iSight because YOU decide when to use your iSight.
    Some apps such as iChat allow you to enable and disable the webcam from menu commands.
    Other apps such as Photo Booth only use the camera when you click the button.
    However, if you REALLY want to disable, scripts like this one can easily disable and enable iSight.
      http://techslaves.org/index.php?page=62
    However, be aware that it simultaneously disables ALL USB webcams when active.
    Although I do not recommend it, you can manually disable your built-in iSight by removing the "QuickTimeUSBVDCDIgitizer.component" file from your computer's HardDriveName > System > Library > QuickTime folder and restarting your Mac. Your built-in iSight should no longer work with any app.
    P.S. Manually moving, renaming, or deleting files outside your Username/Documents folder
       is generally a BAD idea unless you KNOW how it will effect OS X.
    EZ Jim
    Mac Pro Quad Core (Early 2009) 2.93Ghz Mac OS X (10.6.6); MacBook Pro (13 inch, Mid 2009) 2.26GHz (10.6.6)
    LED Cinema Display; G4 PowerBook 1.67GHz (10.4.11); iBookSE 366MHz (10.3.9); External iSight; iPod4touch4.2.1

  • What is the most efficient way to turn an array of 16 bit unsigned integers into an ASCII string such that...?

    What is the most efficient way to turn a one dimensional array of 16 bit unsigned integers into an ASCII string such that the low byte of the integer is first, then the high byte, then two bytes of hex "00" (that is to say, two null characters in a row)?
    My method seems somewhat ad hoc. I take the number, split it, then interleave it with 2 arrays of 4095 bytes. Easy enough, but it depends on all of these files being exactly 16380 bytes, which theoretically they should be.
    The size of the array is known. However, if it were not, what would be the best method?
    (And yes, I am trying to read in a file format from another program)

    My method:
    Attachments:
    word_array_to_weird_string.vi ‏18 KB

  • Looking for a simple way to convert a string to title case

    New to LiveCycle and Javascript.  Looking for a simple way to convert a string to title case, except acronyms.  Currently using the the following, it converts acronyms to lower case:
    var str  =  this.rawValue;
    var upCase = str.split(" ");
    for(i=0; i < upCase.length; i++) {
    upCase[i] = upCase[i].substr(0,1).toUpperCase() + upCase[i].substr(1).toLowerCase();
    this.rawValue = upCase.join(' ');

    Thanks for the reply.
    Found the following script in a forum, which works fine as a "custom validation script" in the.pdf version of my form.  However, it will not work in LiveCycle?  The problem seems to be with
    "return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g"
    function toTitleCase(str) {
    var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
        return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
    if (index > 0 && index + match.length !== title.length &&
      match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
    (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
    title.charAt(index - 1).search(/[^\s-]/) < 0) {
    return match.toLowerCase();
    if (match.substr(1).search(/[A-Z]|\../) > -1) {
      return match;
      return match.charAt(0).toUpperCase() + match.substr(1);
    event.value = toTitleCase(event.value);

  • I'm looking simple way XML-View from a string?

    Hi,
    there is a nice facility to show a XML-Tree in the Microsoft Internet-Explorer from a XML-file on the PC.
    Is there a simple way like this in ABAP?
    My mission is to read a XML-String from a table and to show the XML-Tree in the SAPGUI.
    I found the method CL_XML_DOCUMENT->DISPLAY, but I'm not sure how to export the XML-String to this class/object.
    Best and regards,
    Stefan

    hi,
    you can use
    call method CL_XML_DOCUMENT->display.
    data : l_string type string.
    data :lo_mxml type ref to cl_xml_document,
          m_document  type ref to if_ixml_document,
          l_dom       type ref to if_ixml_element,
          l_ele       type ref to if_ixml_element,
          l_ele1      type ref to if_ixml_element,
          m_doctype   type ref to if_ixml_document_type,
          g_ixml      type ref to if_ixml,
          l_text      type ref to if_ixml_text,
          ls_srctab1  type xstring,
          l_retcode type sysubrc.    "#EC *.
    create object lo_mxml.
    move 'cxml SYSTEM "http://b2b.xxxxx.com/"' to l_string.
    class cl_ixml definition load.
    g_ixml = cl_ixml=>create( ).
    m_document = g_ixml->create_document( ).
      call method m_document->create_document_type
        exporting
           name   = 'cXML'
        receiving
          rval   = m_doctype.
    call method m_document->set_document_type
        exporting
          document_type = m_doctype.
      l_dom = m_document->create_element( name = 'cXML' ).
      l_retcode = m_document->append_child( l_dom ).
      move gw_respond-payload_id to l_string.
    *____setting attribute payload id for cxml tag
      call method l_dom->set_attribute
        exporting
          name    = 'payloadID'
          value   = l_string
         NODE    = LO_NODE
        receiving
          rval = l_retcode.
    call method lo_mxml->display.
    cheers,
    sasi

  • Simpler way to sort 2-d string array?

    I have a long 2d string array, and I would like to sort by the 2nd value. It originates as:
        public static final String names[][] = {
         {"000000", "Black"},
         {"000080", "Navy Blue"},
         {"0000C8", "Dark Blue"},
         {"0000FF", "Blue"},
            {"000741", "Stratos"},
         {"FFFFF0", "Ivory"},
         {"FFFFFF", "White"}
        };As you can see, they are pre-sorted by the hex values. That is useful for part of the app.
    There are 1,567 entries. I would like to alphabetize the color names and place them in a list widget. I need to keep the associated hex color values with the name values. All I can think of to do something like:
    1) make a temporary long 1-d string array
    2) fill it by loop that appends the hex values to the name values: temp[i] = new String (names[1] + names[i][0])
    3) sort temp[] with built in Java sort
    4) make a permanent new string array, hexValues[] for the hex values
    5) copy the last 6 characters of each item to hexValues[]
    6) truncate the last 6 characters of each item in temp[]
    7) build list widget with temp[]
    Is there a more elegant way? What I'd really like to do is build a 1-d array of int's, with the values representing the alphabetized locations of the names. However, I don't see any built-in which would do that kind of indirect sort.
    Second question -- Can the backgrounds of each item in a list widget be a different color? Ideally the list would show the color name in black or white, and the its color value as background. Specifically, I'm trying to build the list accomplished by the Javascript code here:
    * http://chir.ag/projects/name-that-color/
    and add it to my Java interactive color wheel:
    * http://r0k.us/graphics/SIHwheel.html
    BTW, I have converted his name that color Javascript (ntc.js) to a native Java class. It is freely distributable, and I host it here:
    * http://r0k.us/source/ntc.java
    -- Rich
    Edited by: RichF on Oct 7, 2010 7:04 PM
    Silly forum software; I can't see what made it go italic at the word new.

    I am implementing a sort infrastructure along the lines of camickr's working example, above. Part of my problem is that I am new to both lists and collections. I've tried searching, and I cannot figure out why the compiler doesn't like my "new":
    public class colorName implements Comparable<colorName>
        String     name, hex;
        int          hsi;
        static List<colorName> colorNames;
        public colorName(String name, String hex)
         float     hsb[] = {0f, 0f, 0f};
         int     rgb[] = {0, 0, 0};
         int     h, s, b;     // b for brightness, same as i
         this.name = name;
         this.hex  = hex;
         // Now we need to calculate hsi,
         this.hsi = (h << 10) + (s << 6) + b;  //  hhhhhhssssiiiiii
        ***   findColorName() performs 3 functions.  First, it
        *** will auto-initialize itself if necessary.  Second,
        *** it will perform 3 sorts:
        ***   -3) byHSI:  sort by HSI and return first element of sorted list
        ***   -2) byNAME: sort by name and return first element of list
        ***   -1) byHEX:  (re)reads ntc.names, which is already sorted by HEX;
        ***               returns first element of list
        *** Third, on 0 or greater, will return the nth element of list
        *** Note: ntc.init() need not have been called.
        public colorName findColorName(int which)
         if (which < -3)  which = -3;
         if (which >= ntc.names.length)  which = ntc.names.length - 1;
         if (which == -1)  colorNames = null;     // free up for garbage collection
         if (colorNames == null)
         {   // (re)create list
             colorNames = new ArrayList<colorName>(ntc.names.length);
             for (int i = 0; i < ntc.names.length; i++)
                 colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
            if (which == -1)  return(colorNames.get(0));
    }On compilation, I receive:
    D:\progming\java\ntc>javac colorName.java
    colorName.java:117: cannot find symbol
    symbol  : constructor colorName(java.lang.String[],java.lang.String[])
    location: class colorName
                    colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
                                   ^
    1 errorLine 117 is the second-to-last executable line in code block. I know it is finding the ntc.names[][] array the ntc.class file. I had forgotten to compile ntc.java, and there were other errors, such as in line 115 where it couldn't find ntc.names.length. Compare camickr's two lines:
              List<Person> people = new ArrayList<Person>();
              people.add( new Person("Homer", 38) );As far as I can tell, I'm doing exactly the same thing. If you have any other feedback, feel free to make it. The full source may be found at:
    * http://r0k.us/rock/Junk/colorName.java
    PS1: I know I don't need the parenthesis in my return's. It's an old habit, and they look funny to me without them.
    PS2: My original design had the "static List<colorName> colorNames;" line defined within the findColorName() method. The compiler did not like that; it appears to be that one cannot have static variables within methods. Anyway, that's why I don't have separate sorting and getting methods. I'm learning; "static" does not mean, "keep this baby around". Its meaning is, "there is only one of these babies per class".
    -- Rich

  • Non ASCII String to Hex

    Hi,
    I am writing an algorithm that first encrypts a String, and then converts that String to Hex String. I can successfully parse Hex Strings into Ascii Strings and vice versa, but when I encrypt I cannot do this anymore. Is there a way to convert a non-ascii character to Hexadecimal and vice versa?
    Thanks in advance

    Maybe so....
    The encrypted value when printed does not format on my screen, and appears as boxes and such.
    The values that I am passing in are a very simple encryption....XOR against a key. Here is that algorithm.
    public byte[] encrypt(byte[] value) {
              byte[] encrypted = new byte[value.length];
              byte[] adjustedKey = getKey();
              while (adjustedKey.length < encrypted.length) {
                   String temp = new String(adjustedKey) + new String(key);
                   adjustedKey = temp.getBytes();
              for (int i = 0; i < value.length; i++) {
                   encrypted[i] = (byte)(adjustedKey[i] ^ value);
              return encrypted;          
    Since this is an XOR, I can use the same method to decrypt as well. This is what produces my non-Ascii characters.
    Is there a way for me to get the byte value of a 1 digit hex value then? this may help some.

  • Convers ascii string to hex string

    I need to send a hex string such as 5051525354A5A6A7A8A9 to a DSP across a serial port.  The string is read in from a file.
    When I send this string to the DSP, it does not recognize the correct hex values.
    If I enter the hex value, 5051525354A5A6A7A8A9, in to a string control that is set to hex display and then change the control to normal display, I get PQRST¥¦§¨©.  When I send this string,  PQRST¥¦§¨©, to the DSP, it recognizes the correct hex values. 
    How can I change the hex string read from the text file to this type of ASCII character conversion?  I've used type cast and the other functions available in LabVIEW with no success.
    This is only one of many strings I need to send so I don't want to hard code PQRST¥¦§¨© or some such string for each message.

    Here's a slightly simpler way.
    Message Edited by altenbach on 08-23-2007 12:17 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    HexStringtoBinaryString.png ‏10 KB
    HexStringtoBinaryString.vi ‏11 KB

  • How can I convert a string of hex values to a hex format string programatically?

    Is there a way to convert a string of the following format:
    1400010107070D0305006A01 ........           ("Normal display" string)
    programatically to:
    1400 0101 0707 0D03 05006A01 ..........      ("Hex display" striing)
    I need to do this in order to calculate a CRC16 value.
    See attached VIs
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_SN_MULTI.vi ‏50 KB
    CMM_CRC16_Calculator.vi ‏23 KB

    You can iterate over the string and use the String to Hex VI. If you work with two bytes of the string at a time you can get a U8 array of the desired binary values. Then when you are complete you can either work with the byte array of convert it back to a string using Byte Array to String.
    EDIT: GerdW typed faster than I did.
    Message Edited by Mark Yedinak on 03-18-2010 02:55 PM
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Turning string into Identifier

    I want to create a jsp instanceof tag taht will take a string as an argument and turn it into tan identifier to test against. e.g.
    String input = "java.lang.String";
    // do somethinng to convert input to identifier object
    boolean isInstance = anotherInputVariable instanceof new Identifier(input);
    Is there a simple way to do this?
    I also want to be able to cast the secondary input into the class represented by the identifier string.. e.g.
    String g = (input) anotherInputVariable;
    How would I do that as well?
    Sorry if this is somewhat coherant... Im on a deathmarch coding project and my brain is awash.

    I want to create a jsp instanceof tag taht will take a
    string as an argument and turn it into tan identifier
    to test against. e.g.
    String input = "java.lang.String";
    // do somethinng to convert input to identifier objectSomething like this?Class c = Class.forName(input);
    boolean isInstance = anotherInputVariable instanceof new Identifier(input);You can't use the instanceof operator, but the Class class has methods that will do what you want - check the API. However, use of these techniques is usually a sign of a bad design.
    Is there a simple way to do this?
    I also want to be able to cast the secondary input
    into the class represented by the identifier string..
    e.g.
    String g = (input) anotherInputVariable;
    How would I do that as well?Impossible - there is no runtime type casting. And it wouldn't do you any good anyway, because at complie time (when you're writing your code) the only information you would have available is that it's an Object, so those are the only methods you could use.

  • Whether there is a simple way to add new Mapping operators on a mapping?

    Whether there is a simple way to add new Mapping operators on existing mapping?
    For example I have a mapping, but now I need to add new Filter or Aggregator operator, so I must delete all connections between attributes, then add new operator, connect source attributes to the input attribute for the operator and so on.
    Is there way to turn down this operations, simply drop new operator on source object or on a connection between two objects, and necessary operations will be automatically executed.
    As I remember in OWB2 something similar existed in a way to add new Filter operator.

    Dmitry,
    Unfortunately there is not. What you should aim for, is to use the group-by-group mapping using match by name (with some additional options, such as ignore source/target prefix, suffix, etc.).
    I.e. if you want to insert another operator, then I recommend you first populate attributes based on an operator that is currently on the mapping delete the old operator (to delete all connections), map into the new operator and add another operator in order to re-create what you previously had. I know it is not ideal... but in my experience it is the most productive way to work.
    Thanks,
    Mark.

  • Is there a way to turn off email batching?

    Email are string attached. Is there a way to turn off?

    Settings>Mail, Contacts, Calendars>Organize By Thread>Off.

  • Is There A Simple Way Of Deleting Invisible Files?

    There's an invisible file/folder that I need to delete but don't know how. Instructions about how to do it that I've come across seem rather unclear.
    Is there a rather simple way of deleting Invisible files?

    If you know the name of the file/folder you can use the free Easy Find
    http://download.cnet.com/EasyFind/3000-2248_4-8707.html
    You can also use the free TinkerTool to turn on all invisible files, then do what you have to do, then turn invisible files off.
    http://bresink.de/osx/TinkerTool.html

  • What best way to turn on all computers remotely using sccm 2012 sp 1

    what best way to turn on all computers remotely using sccm  2012
    and what the difference  between wake on lan and out of band service point role

    Hey!!! I am a 1E engineer and MVP... we started the power management movement with our very first software product, created around 12 or so years ago, called 1E WakeUp. The complete solution which manages power on (integrated with SCCM, or stand alone if
    you are not an SCCM shop) and power off (under a tightly controlled process) is called
    NightWatchman
    Here is a
    recent blog post I authored that was the last in a series documenting the entire wake-up process including how it integrates with SCCM or stood up standalone. It contains links to those earlier posts that explain our entire technology, so you will likely
    want to read all of them in order for a full understanding of our technology. It works incredibly well, is the most mature solution in the industry, and is extremely simple to install with minimal resources.
    If you have any questions, feel free to reach out to me privately
    Ed Aldrich | 1E | Pre-Sales Solutions Engineer | ConfigManager MVP 2003-2012

  • String to Hex

    I was wondering if there is a way to turn a string returned from a .ini file can be converted to an integer(a hexidecimal colour code) for example, the string is
    string b = "0x000000"
    i used
    int k = Integer.parseInt(b);
    and it gives nasty errors because of the 0x at the begging, Any help would be greatley appreciated.

    You still may need to strip the 0x from the front of the String prior to doing a parseInt(), even with a radix of 16.
    RD-R
    � {�                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Error in CC

    error in communication channel monitoring, Error while processing message '224abc5-4a13-471a-2d45-a67f6b5466ay2'; detailed error description: com.sap.aii.adapter.jms.api.channel.filter.MessageFilterException: The XI AF module processor call failed si

  • Strange request: Dial-up

    Does anyone still have a dial-up connection (or a really really slow internet connection)? My boss wants to see how fast/slow our new website will load on a computer with really slow internet like dial-up... and I don't know anyone who has it. If any

  • BUG: This action could not be completed. Try again later.

    In trying to update the app, "Foursquare (Now)" via Preware, I am encountering the error, "This action could not be completed. Try again later."  I previously had installed this app, which ran normally.  I was updating the app with the newest version

  • Satellite 5200 - Video memory corruption

    One month ago I encountered a problem with a slightly garbled screen on the internal and external displays. More or less visible vertical strips appear on the screen. They are mainly blue on dark background (best visible) or yellow on white backgroun

  • Help???  I can not find the layers task bar.

    My task bar is not showing at the bottom of the page.  How do I open it?