Converting byte[] to short, long, etc.

I need to packetize the data with my own header embedded in the data. The header field is composed of data types: short, byte, and long. Since the header will be transported over the network using UDP socket, it will have to be converted to type byte[].
Is there a clean way to convert from byte[] to short, and long data types? Or do I have to concatenate bytes and type cast them? How do I even type cast byte[] to short? Thanks.

Have a look at the ByteBuffer class. You can wrap a byte
array in such a buffer and write other types (like ints or longs etc)
to the byte array through the buffer. Of course you can read those
values back again using the buffer.
kind regards,
Jos

Similar Messages

  • Converting bytes to shorts using arrays and NIO buffers - is this a bug?

    I'm benchmarking the various methods for converting a sequence of bytes into shorts. I tried copying a byte array, a direct NIO buffer and a non-direct NIO buffer to a short array (using little-endian byte order). My results were a little confusing to me. As I understand it, direct buffers are basically native buffers - allocated by the OS instead of on the runtime's managed heap, hence their higher allocation cost and ability to perform quicker IO with channels that can use them directly. I also got the impression that non-direct buffers (which have a backing array) are basically just regular Java arrays wrapped in a ByteBuffer.
    I didn't expect a huge difference between the results of my three tests, though I thought the two NIO methods might perform a bit quicker if the virtual machine was smart enough to notice that little-endian is my system's native byte order (hence allowing the chunk of memory to simply be copied, rather than applying a bunch of shifts and ORs to the bytes). Conversion with the direct NIO buffer was indeed faster than my byte array method, however the non-direct NIO buffer performed over ten times slower than even my array method. I can see it maybe performing a millisecond or two slower than the array method, what with virtual function call overhead and a few if checks to see what byte order should be used and what not, but shouldn't that method basically be doing exactly the same thing as my array method? Why is it so horribly slow?
    Snippet:
    import java.nio.*;
    public class Program {
      public static final int LOOPS = 500;
      public static final int BUFFER_SIZE = 1024 * 1024;
      public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16) {
        for(int i = 0; i < buffer16.length; i += 2){
          buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
      public static void main(String[] args) {
        short[] shorts = new short[BUFFER_SIZE >>> 1];
        byte[] arrayBuffer = new byte[BUFFER_SIZE];
        ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        long start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) copyByteArrayToShortArrayLE(arrayBuffer, shorts);
        long timeArray = System.currentTimeMillis() - start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) directBuffer.asShortBuffer().get(shorts);
        long timeDirect = System.currentTimeMillis() - start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) nonDirectBuffer.asShortBuffer().get(shorts);
        long timeNonDirect = System.currentTimeMillis() - start;
        System.out.println("Array:      " + timeArray);
        System.out.println("Direct:     " + timeDirect);
        System.out.println("Non-direct: " + timeNonDirect);
    }Result:
    Array:      328
    Direct:     234
    Non-direct: 4860

    Using JDK1.6.0_18 on Ubuntu 9.1 I typically get
    Array: 396
    Direct: 550
    Non-direct: 789
    I think your tests are a little too short for accurate timings because they are likely to be significantly influenced by the JIT compilation.
    If I change to use a GIT warmup i.e.
    public static final int LOOPS = 500;
        public static final int WARMUP_LOOPS = 500;
        public static final int BUFFER_SIZE = 1024 * 1024;
        public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
            for (int i = 0; i < buffer16.length; i += 2)
                buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
        public static void main(String[] args)
            short[] shorts = new short[BUFFER_SIZE >>> 1];
            byte[] arrayBuffer = new byte[BUFFER_SIZE];
            ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
            ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
            long start = 0;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                copyByteArrayToShortArrayLE(arrayBuffer, shorts);
            long timeArray = System.currentTimeMillis() - start;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                directBuffer.asShortBuffer().get(shorts);
            long timeDirect = System.currentTimeMillis() - start;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                nonDirectBuffer.asShortBuffer().get(shorts);
            long timeNonDirect = System.currentTimeMillis() - start;
            System.out.println("Array:      " + timeArray);
            System.out.println("Direct:     " + timeDirect);
            System.out.println("Non-direct: " + timeNonDirect);
        }then I typically get
    Array: 365
    Direct: 528
    Non-direct: 750
    and if I change to 50,000 loops I typically get
    Array: 37511
    Direct: 57199
    Non-direct: 73913
    You also seem to have a bug in your copyByteArrayToShortArrayLE() method. Should it not be
    public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
            for (int i = 0; i < buffer8.length; i += 2)
                buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
        }Edited by: sabre150 on Jan 27, 2010 9:07 AM

  • Converting Byte [] into float []

    Hi, I read the contents of a file into a byte array and am now trying to convert it into a float array.
    here is the code I am using
    public static float [] bytetofloat(byte [] convert){
        float [] data = new float [convert.length/2];
        for(int i = 0;i<convert.length;i+=2){
            for(int j = 0; j <data.length;j++){
            short valueAsShort = (short)( (convert[i] << 8)  | (convert[i+1] & 0xff));
            float valueAsFloat = (float)valueAsShort;
            System.out.println(valueAsFloat);
            valueAsFloat = data[j];
            System.out.println(data[j]);
        }can anyone see anythign wrong with the way I am doing this? I cant see anythign wrong but need to make sure its fine before I can continue.
    any advice on this or a better way to do it would be much appreciated.

    ultiron wrote:
    I'm pretty sure they do. The way im doing it is by taking 2 byte values and changing them to a 16 bit float.
    the way the bytes are shift they should only take up 16 bits.It's not that simple.
    First, a float in Java is always 4 bytes. The fact that it has an integer value that can fit into two bytes is irrelevant
    Second, floating point representation is not the same 2s complement that's used for byte, short, int, and long, so you're not just shifting the bits.
    For eample:
    1,  int: 00000000 00000000 00000000 00000001
    1, float: 00111111 10000000 00000000 00000000
    -1,  int: 11111111 11111111 11111111 11111111
    -1, float: 10111111 10000000 00000000 00000000Having said that, you're casting, so your step of going from short to float is correct. It doesn't just shift; it does conversions like the above. The caveats are:
    1) Is your conversion from bytes to short correct? That depends on what those bytes are supposed to be. If they're big-endian representations of 2-byte, 2s-complement numbers, then your code looks correct. You'll still have to test it of course. You'll want to focus on corner cases.
    00 00 --> 0
    00 01 --> 1
    10 00 --> 4096
    7f ff --> 32767
    80 00 --> -32768
    ff ff --> -1
    2) Can float hold all of short's values? I think it can. It obviously can't hold all of int's values, but I think it's precision is sufficient to cover short.
    By the way, is there a reason you're using float instead of double? Unless you're in an extremely memory-constrained environment, there's no reason to use double.

  • Converting byte[] to Class without using defineClass() in ClassLoader

    so as to de-serialize objects that do not have their class definitions loaded yet, i am over-riding resolveClass() in ObjectInputStream .
    within resolveClass() i invoke findClass() on a network-based ClassLoader i created .
    within findClass() , i invoke
    Class remoteClass = defineClass(className, classImage, 0, classImage.length);
    and that is where i transform a byte[] into a Class , and then finally return a value for the resolveClass() method.
    this seems like a lengthy process. i mean, within resolveClass() i can grab the correct byte[] over the network.
    then, if i could only convert this byte[] to a Class within resolveClass() , i would never need to extended ClassLoader and over-ride findClass() .
    i assume that the only way to convert a byte[] to a Class is using defineClass() which is hidden deep within ClassLoader ? there is something going on under the hood i am sure. otherwise, why not a method to directly convert byte[] to a Class ? the byte[] representation of a Class always starts with hex CAFEBABE, and then i'm sure there is a standard way to structure the byte[] .
    my core issue is:
    i am sending objects over an ObjectInputStream created from a Socket .
    at the minimum, i can see that resolveClass() within ObjectInputStream must be invoked at least once .
    but then after that, since the relevant classes for de-serialization have been gotten over the network, i don't want to cascade all the way down to where i must invoke:
    Class remoteClass = defineClass(className, classImage, 0, classImage.length);
    again. so, right now, within resolveClass() i am using a Map<String, Class> to create the following class cache:
    cache.put(objectStreamClass.getName(), Class);
    once loaded, a class should stay loaded (even if its loaded in the run-time), i think? but this is not working. each de-serialization cascades down to defineClass() .
    so, i want to short-circuit the need to get the class within the resolveClass() method (ie. invoke defineClass() only once),
    but using a Map<String, Class> cache looks really stupid and certainly a hack.
    that is the best i can do to explain my issue. if you read this far, thanks.

    ok. stupid question:
    for me to use URLClassLoader , i am going to need to write a bare-bones HTTP server to handle the class requests, right?Wrong. You have to deploy one, but what's wrong with Apache for example? It's free, for a start.
    and, i should easily be able to do this using the com.sun.net.httpserver library, right?Why would you bother when free working HTTP servers are already available?

  • Converting byte from dec to hex

    Hi All,
    I'm having a problem converting byte from decimal to hex - i need the following result:
    if entered 127 (dec), the output should be 7f (hex).
    The following method fails, of course because of NumberFormatException.
        private byte toHexByte(byte signedByte)
            int unsignedByte = signedByte;
            unsignedByte &= 0xff;
            String hexString = Integer.toHexString(unsignedByte);
            BigInteger bigInteger = new BigInteger(hexString);
            //byte hexByte = Byte.parseByte(hexString);
            return bigInteger.byteValue();
        }

    get numberformatexception because a lot of hex digits cannot be transformed into int just like that (ie f is not a digit in decimal) heres some code that i used for a pdp11 assembler IDE... but this is for 16-bit 2s complement in binary/octal/decimal/hex , might be useful for reference as example though
        public static String getBase(short i, int base){
            String res = (i>=0)? Integer.toString((int)i,base)
                    : Integer.toString((int)65536+i,base) + " ("+Integer.toString((int)i,base)+")";
           StringBuffer pad= new StringBuffer();
            for(int x = 0; x < 16 - res.length() ; x++){
                pad.append("0");
            res = pad.toString() + res;
            return res;
        }

  • How to convert bytes[] into File object

    hi
    how to convert byte array into File object
    pls.. help me
    Regards
    srinu

    rrrr007 wrote:
    Hi,
    How to convert bytes[] into multipage File object?? ]There's no such thing as a "multipage File object." You ought to re-read this thread closely, and read the [API docs for File|http://java.sun.com/javase/6/docs/api/java/io/File.html] to clear up your confusion about what a File object is.
    I used the java.io.SequenceInputStream to concatenate two input streams (basically .pdf files) into a single input stream. I need to create a single multipage pdf file using this input stream. Then you need a pdf API, like iText or fop. You can't just concatenate pdf files, word docs, excel sheets, etc., like you can text files. Google for java pdf api.

  • How to convert bytes[] into multipage File object

    Hi,
    How to convert bytes[] into multipage File object??
    I used the java.io.SequenceInputStream to concatenate two input streams (basically .pdf files) into a single input stream. I need to create a single multipage pdf file using this input stream.
    Thanks for you help in advance..

    Only text format allows you to concatenate two files together to get a longer files.
    Most formats have a header and a footer and so you cannot simply add one to the other.
    You need to use a PDF API which will allow you to build the new document (if one exists)

  • Convert byte array to table of int

    [http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print|http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print] Hello friends.
    I'm pretty new with PL/SQL.
    I have code that run well on MSSQL and I want to convert it to PL/SQL with no luck.
    The code converts byte array to table of int.
    The byte array is actually array of int that was converted to bytes in C# for sending it as parameter.
    The TSQL code is:
    CREATE FUNCTION dbo.GetTableVarchar(@Data image)
    RETURNS @DataTable TABLE (RowID int primary key IDENTITY ,
    Value Varchar(8000))
    AS
    BEGIN
    --First Test the data is of type Varchar.
    IF(dbo.ValidateExpectedType(103, @Data)<>1) RETURN
    --Loop thru the list inserting each
    -- item into the variable table.
    DECLARE @Ptr int, @Length int,
    @VarcharLength smallint, @Value Varchar(8000)
    SELECT @Length = DataLength(@Data), @Ptr = 2
    WHILE(@Ptr<@Length)
    BEGIN
    --The first 2 bytes of each item is the length of the
    --varchar, a negative number designates a null value.
    SET @VarcharLength = SUBSTRING(@Data, @ptr, 2)
    SET @Ptr = @Ptr + 2
    IF(@VarcharLength<0)
    SET @Value = NULL
    ELSE
    BEGIN
    SET @Value = SUBSTRING(@Data, @ptr, @VarcharLength)
    SET @Ptr = @Ptr + @VarcharLength
    END
    INSERT INTO @DataTable (Value) VALUES(@Value)
    END
    RETURN
    END
    It's taken from http://www.codeproject.com/KB/database/PassingArraysIntoSPs.aspx?display=Print.
    The C# code is:
    public byte[] Convert2Bytes(int[] list)
    if (list == null || list.Length == 0)
    return new byte[0];
    byte[] data = new byte[list.Length * 4];
    int k = 0;
    for (int i = 0; i < list.Length; i++)
    byte[] intBytes = BitConverter.GetBytes(list);
    for (int j = intBytes.Length - 1; j >= 0; j--)
    data[k++] = intBytes[j];
    return data;
    I tryied to convert the TSQL code to PL/SQL and thats what I've got:
    FUNCTION GetTableInt(p_Data blob)
    RETURN t_array --t_array is table of int
    AS
    l_Ptr number;
    l_Length number;
    l_ID number;
    l_data t_array;
    BEGIN
         l_Length := dbms_lob.getlength(p_Data);
    l_Ptr := 1;
         WHILE(l_Ptr<=l_Length)
         loop
              l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
              IF(l_ID<-2147483646)THEN
                   IF(l_ID=-2147483648)THEN
                        l_ID := NULL;
                   ELSE
                        l_Ptr := l_Ptr + 4;
                        l_ID := to_number( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
                   END IF;
                   END IF;
    l_data(l_data.count) := l_ID;
              l_Ptr := l_Ptr + 4;
         END loop;
         RETURN l_data;
    END GetTableInt;
    This isn't work.
    This is the error:
    Error report:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    06502. 00000 - "PL/SQL: numeric or value error%s"
    I think the problem is in this line:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    but I don't know how to fix that.
    Thanks,
    MTs.

    I'd found the solution.
    I need to write:
    l_ID := utl_raw.cast_to_binary_integer( DBMS_LOB.SUBSTR(p_Data, 4,l_ptr));
    instead of:
    l_ID := to_number( DBMS_LOB.SUBSTR (p_Data, 4, l_ptr));
    The performance isn't good, it's take 2.8 sec to convert 5000 int, but it's works.

  • Amend Short & Long Text in GL A/c master

    Hello All,
    We created a GL account without reference to an eisting account at Chart of Accounts level. We do not attach it to any Company code. In this situation we are able to amend the short & long text of the GL account after it is saved.
    But in case we create the GL account with reference to an existing account at CoA level not attaching it to any Co. code & saving it; we are now NOT able to amend the short & long text of the account. We are allowed to amend only the GL account group.
    Please let me know by using what method we will be able to amend the short & long text of this GL account.
    Thanks
    Shreenath

    Hello,
    This short & Long text could be finally resolved by using transaction OB_GLACC13 - Mass changes
    Kaustubh

  • Since loading Lion, I've experienced much more instability than Snow Leopard. In particular, Mail crashes with regularity, full-screen apps seem to run slower and show the beach ball more often for longer, etc.  I'm disappointed with the performance. Any

    Since loading Lion, I've experienced much more instability than Snow Leopard. In particular, Mail crashes with regularity, full-screen apps seem to run slower and show the beach ball more often for longer, etc. I love the features, but I'm disappointed with the performance. Any help coming from Apple?  I've been sending them so many reports after crashes, that their file must be full!

    Summoning max. courage, I did what you advised. Here is the result. What does this tell you? My Lion 7.2 (mid 2011 iMac) has several annoying glitches (which I have so far tolerated through gritted teeth) but none that have actually stopped me working.
    BTW, I see several items involving CleanMyMac which I did not know I had. It is generally villified as a trouble-maker. Spotlight can't find an app. or a utility of that name. How can I get rid of what's there please? Just delete?
    Last login: Thu Nov  3 20:55:11 on console
    Steve-Kirkbys-iMac:~ stevekirkby$ kextstat -kl | awk ' !/apple/ { print $6 $7 } '
    com.AmbrosiaSW.AudioSupport(4.0)
    Steve-Kirkbys-iMac:~ stevekirkby$ sudo launchctl list | sed 1d | awk ' !/0x|apple|com\.vix|edu\.|org\./ { print $3 } '
    Password:
    com.openssh.sshd
    com.stclairsoft.DefaultFolderXAgent
    com.microsoft.office.licensing.helper
    com.bombich.ccc.scheduledtask.067493DB-2728-4DF3-87D8-092EF69086E8
    com.bombich.ccc
    com.adobe.SwitchBoard
    Steve-Kirkbys-iMac:~ stevekirkby$ launchctl list | sed 1d | awk ' !/0x|apple|edu\.|org\./ { print $3 } '
    com.sony.PMBPortable.AutoRun
    uk.co.markallan.clamxav.freshclam
    com.veoh.webplayer.startup
    com.macpaw.CleanMyMac.volumeWatcher
    com.macpaw.CleanMyMac.trashSizeWatcher
    com.adobe.ARM.202f4087f2bbde52e3ac2df389f53a4f123223c9cc56a8fd83a6f7ae
    com.adobe.AAM.Scheduler-1.0
    Steve-Kirkbys-iMac:~ stevekirkby$ ls -1A {,/}Library/{Ad,Compon,Ex,Fram,In,La,Mail/Bu,P*P,Priv,Qu,Scripti,Sta}* 2> /dev/null
    /Library/Components:
    /Library/Extensions:
    /Library/Frameworks:
    AEProfiling.framework
    AERegistration.framework
    ApplicationEnhancer.framework
    AudioMixEngine.framework
    FxPlug.framework
    NyxAudioAnalysis.framework
    PluginManager.framework
    ProFX.framework
    ProMetadataSupport.framework
    TSLicense.framework
    iLifeFaceRecognition.framework
    iLifeKit.framework
    iLifePageLayout.framework
    iLifeSQLAccess.framework
    iLifeSlideshow.framework
    /Library/Input Methods:
    /Library/Internet Plug-Ins:
    AdobePDFViewer.plugin
    EPPEX Plugin.plugin
    Flash Player.plugin
    Flip4Mac WMV Plugin.plugin
    JavaAppletPlugin.plugin
    Quartz Composer.webplugin
    QuickTime Plugin.plugin
    SharePointBrowserPlugin.plugin
    SharePointWebKitPlugin.webplugin
    Silverlight.plugin
    flashplayer.xpt
    iPhotoPhotocast.plugin
    nsIQTScriptablePlugin.xpt
    /Library/LaunchAgents:
    com.adobe.AAM.Updater-1.0.plist
    com.sony.PMBPortable.AutoRun.plist
    /Library/LaunchDaemons:
    com.adobe.SwitchBoard.plist
    com.apple.remotepairtool.plist
    com.bombich.ccc.plist
    com.bombich.ccc.scheduledtask.067493DB-2728-4DF3-87D8-092EF69086E8.plist
    com.microsoft.office.licensing.helper.plist
    com.stclairsoft.DefaultFolderXAgent.plist
    /Library/PreferencePanes:
    .DS_Store
    Application Enhancer.prefPane
    Default Folder X.prefPane
    DejaVu.prefPane
    Flash Player.prefPane
    Flip4Mac WMV.prefPane
    /Library/PrivilegedHelperTools:
    com.bombich.ccc
    com.microsoft.office.licensing.helper
    com.stclairsoft.DefaultFolderXAgent
    /Library/QuickLook:
    iWork.qlgenerator
    /Library/QuickTime:
    AppleIntermediateCodec.component
    AppleMPEG2Codec.component
    DesktopVideoOut.component
    DivX 6 Decoder.component
    FCP Uncompressed 422.component
    Flip4Mac WMV Advanced.component
    Flip4Mac WMV Export.component
    Flip4Mac WMV Import.component
    LiveType.component
    /Library/ScriptingAdditions:
    .DS_Store
    Adobe Unit Types.osax
    Default Folder X Addition.osax
    /Library/StartupItems:
    Library/Address Book Plug-Ins:
    Library/Frameworks:
    EWSMac.framework
    Library/Input Methods:
    .localized
    Library/Internet Plug-Ins:
    Library/LaunchAgents:
    com.adobe.AAM.Updater-1.0.plist
    com.adobe.ARM.202f4087f2bbde52e3ac2df389f53a4f123223c9cc56a8fd83a6f7ae.plist
    com.macpaw.CleanMyMac.trashSizeWatcher.plist
    com.macpaw.CleanMyMac.volumeWatcher.plist
    com.veoh.webplayer.startup.plist
    uk.co.markallan.clamxav.freshclam.plist
    Library/PreferencePanes:
    .DS_Store
    Perian.prefPane
    WindowShade X.prefPane
    Library/QuickTime:
    AC3MovieImport.component
    Perian.component
    Library/ScriptingAdditions:
    Steve-Kirkbys-iMac:~ stevekirkby$

  • Fail to boot (short-short-short-long beep code) after M92p BIOS Update

    Hi, 
    I recently updated my BIOS to the latest version using the System Update tool from Lenovo. For a while everything seemed to be working alright, as the BIOS was dowloaded and the computer rebooted. After rebooting the first time i was presented with the BIOS utility, and noticed that the update was progressing. 
    After 20 or so seconds the computer rebooted again. This is where my problems began. The computer immediately started beeping this short-short-short-long melody from the speakers. I thought this was normal, so I left the computer on for quite a while. 
    However, the beeping never stopped. Now the beeping resumed the instant i plug the power back in. I have yet been able to actually getting any sort of information on-screen telling me what's wrong. 
    I've tried following the "Recovering from a POST/BIOS update failure" on page 267 of the Hardware Maintenance Manual, but no luck with that so far. No matter where I place the jumper, the beeping code is the same short-short-short-long melody (yeah, it sounds like a disney tune or something).
    Any bright ideas? The machine type is a M92p 2992-B3G
    I'd hate to have to send it in for repairs, and Lenovo's Norwegian support line doesn't open until Monday, and there seems to be no way to call their 800-number in the states from here
    Oh, and would this be covered by my warranty if repairs / motherboard replacement is the only way out?
    UPDATE #1:
    I found this in the manual;
    3 short beeps and then 1 long beep DRAM memory
    error
    Perform the following actions in order.
    1. Make sure the memory module(s) are properly seated
    in the connector(s).
    2. Replace the memory module(s).
    3. Replace the system board.
    This is pretty much Lenovo's way of saying "You're screwed", isn't it?
    UPDATE #2: 
    I've now tried pretty much everything;
    The solution as proposed on page 267 in the Hardware Maintenance Manual
    Unplugging all cables and harddrives before booting
    Removing my PCIe video card and PCI Wireless NIC before booting
    Removing all memory modules, and trying 1 and 1 module
    Moved a memory module from another machine that I know is working
    No luck so far. 
    Ideas would be welcome at this point

    I'm glad to hear it's just a simple memory error, however the original problem in this post is a bit more than just a memory problem.
    This became a problem after a BIOS update, so somewhere along the way one of Lenovo's developer screwed up badly, and it's been bugging me ever since. There's absolutely no way for me to use any PCI-e card with my M92p. 
    I've tried 6 different cards, 3-4 different memory module combinaties, with our without harddrives plugged in, and every thinkable combination of these.
    No luck. Therefore, I simply conclude that Lenovo are dicks, and we all know what dicks enjoy doing; **bleep**ing people over.
    I've given up on the issue, and I'll never buy a Lenovo again after this.

  • Converting bytes to pixels???

    Hi Everyone,
    My Jdev version is 11.1.2.3.0.
    I have deloped one ADF applicaton which is working fine.
    Now i have added a table to the page which has 3 columns. The width of the column in ADF page should be equal to width of the column in the database.
    How can i convert bytes to pixels in my ADF page.
    The three column's width in database are: 200Bytes, 250Bytes, 150Bytes. Now i need to specify the width in pixels in ADF.
    how can i do that?
    Any ways to do that?
    Thanks.

    Yeah I meant e[i] - sorry about that.
    When you say "diagram the to / from arrays" do you mean you want to see their definition & initialisation? If so, please see below:
    numBands, length & width are the three fields read in from the image header.
    byte[] imageDataByte = new byte[numBands * length * width];
              ra.read(imageDataByte,0,numBands * length * width);
              int[] iD = new int[numBands * length * width];
              int count = 0;     
              int[] imageData = new int[numBands * length * width];
              for (int x = 0; x < length; x++)
              for (int y = 0; y < numBands; y++)
              for (int z = 0; z < width; z++)
                   imageData[(length*z+x) + (length* width*y)] += imageDataByte[(length*z+x) + (length* width*y)] << ((length*z+x) + (length* width*y)*512);     
                   count = count + 1;
                   System.out.println(count + ": " + imageData[(length*z+x) + (length* width*y)]);
    Any help would be greatly appreciated.
    Many thanks,
    CG.

  • Convert from String to Long

    Hello Frineds I want to convert from String to Long.
    My String is like str="600 700 250 300" and I want to convert it to long and
    get the total value in to the long variable.like the total of str in long varible should be 1850.
    Thank You
    Nilesh Vasani

    Maybe this would work?
    StringTokenizer st = new StringTokenizer(yourString, " ");
    long l = 0;
    while(st.hasMoreTokens()) {
        l += Long.parseLong(st.nextToken()).longValue();
    }

  • Read byte from a long

    Hi,
    How can I read bytes from a long. i..e read one byte by one byte from long.
    Naman Patel

    ok here is my problem how do i ignore the sign byte i.e please check this code
    long nr=1345345333L, add=7, nr2=0x12345671L;
              long tmp;
              long[] result = new long[2];
              char[] pwd = password.toCharArray();
              for (int pCount = 0; pCount < pwd.length; pCount++){
                   if (pwd[pCount] == ' ' || pwd[pCount] == '\t')
                        continue;
                   tmp= (long) pwd[pCount];
                   nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
                   nr2+=(nr2 << 8) ^ nr;
                   add+=tmp;
              result[0]=nr & (((long) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
              result[1]=nr2 & (((long) 1L << 31) -1L);
              int i = 0;
              long x = result[0];
              byte b[] = longToBytes(x);
              String str = "";
              i = 0;
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f" + b);
                             str += "0";
                        break;
                   i++;
              i = 0;
              str += Long.toHexString(result[0]);
              x = result[1];
              b = longToBytes(x);
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f");
                             str += "0";
                        break;
                   i++;
              str += Long.toHexString(result[1]);

  • I had paid for service to sign pdf, write text on pdfs and convert to word and back etc. Its now asking me to pay for a new service to be able to convert pdf to word, what is going on here?

    I had paid for service to sign pdf, write text on pdfs and convert to word and back etc. Its now asking me to pay for a new service to be able to convert pdf to word, what is going on here?

    Hi,
    I checked your account, your Export PDF service has been expired on Sep 24, 2014.
    Kindly contact our chat support: http://helpx.adobe.com/x-productkb/global/service-b.html
    Regards,
    Florence

Maybe you are looking for