Array Copy Problem

ARRAY COPY DOESN'T WORK. DO NOT ATTEMPT TO USE IT IN YOUR REPLY TO THIS TOPIC. array copy says that you need the same type of object in the arrays. I'm making a method in a class called SUPERARRAYUTIL where this isn't the case. They all extend from a class i made called SUPERARRAY (in javacase caps tho, i just like to use upper case), but that doesnt help me. I'm short on time and i want to post this right now, so i won have any code right away but here is how i'm gonna do it:
1) Static method takes parameters superArray array, superArray newelements, and int start
2) Make a temp array that would be big enough to fit array, and the newelements at postion start in array
3) copy over array using a for loop, starting at 0 in temp.
4) copy over newelements using a for loop, starting at start in temp.
Then i will make non-static methods for superArrayUtil that will use the static methods in superArrayUtil. I will also make a method like System.arraycopy but will call a method called cut to trim the array of new elements and then call this arraycopy to copy it into the dest array, and then another non-static method for that method too.
Basically i just need ideas or comments cause so far i ran into some weird problems or any suggestions if there's a better way to copy arrays in the general way of array1 into array2 at a starting position.

Deo_Favente wrote:
ARRAY COPY DOESN'T WORK.
YES. YES IT DOES. WHY DO YOU THINK THAT IT DOESNT WORK? WHY DON'T YOU POST WHATEVER CODE THAT YOU DO HAVE THAT IS CAUSING YOU PROBLEMS AND THEN MAYBE WE COULD WORK WITH IT. I THINK THAT'S A BETTER IDEA PERSONALLY, AT LEAST OPPOSED TO WHAT YOU DID HERE._+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Array copying problems

    I'm sure this is a stupid question, but I'm not immensly knowledgeable about all the ins and outs of Java yet.
    I have 2 arrays of 81 elements, one known as groups and one as tempGrps. I used the System.arraycopy(groups,0,tempGrps,0,81) to copy groups to tempGrps. The problem I am encountering is that when groups is modified after the arraycopy, the same modifications are made to tempGrps. I have a small routine in place that checks the contents of tempGrps. When the arraycopy command is in place, tempGrps has the modifications that are made to groups also made to it. When the command is not there, tempGrps remains empty(this was tested to make sure I wasn't somehow modifying it somewhere else). What is going on here? The entire reason for the tempGrps array was to hold a temporary backup of the groups array.

    Could you explain this please? I mean, when I say
    MyObject = new
    MyObject(objectToCopy);How do I end up with
    the wrong type of Object?Easily: When objectToCopy is a MyCustomObject that is
    derived from MyObject.I think I see what you're saying - though, by explicitly saying that (woops, forgot the reference name there) myObject is of type MyObject, it's obvious you wanted a MyObject out of that ctor call, and since MyCustomObject is a MyObject then I think it's a stretch to say you get the wrong object type back.
    >
    Disclaimer: I haven't really read the article yet and
    don't feel strongly for either side of the argument,
    that's just one problem I've spotted.

  • Stuck on array of array copy problem

    I've got one array, outputMatrix[][] which is bigger that array matrix[][], and I want to copy matrix into outputMatrix, but off set the copy by a certain amount (to the right by EXTRA_COLUMN_TEXT and down by EXTRA_ROW_TEXT)
    I've tried     for (int i = 0; i < matrix.length; i++ ) {
          System.arraycopy(matrix, 0, outputMatrix[i + EXTRA_ROW_TEXT], EXTRA_COLUMN_TEXT, matrix.length);
    but it fails (java.lang.ArrayStoreException
    ) everytime. What am I doing wrong. I'm really stuck :(

    for(int i=EXTRA_ROW_TEXT, m=0; i<(matrix.length+EXTRA_ROW_TEXT); i++, m++)
    for(int j=EXTRA_COLUMN_TEXT, n=0; j<(matrix(i).length+EXTRA_COLUMN_TEXT); j++, n++)
    outputMatrix(i)(j)=Matrix(m)(n);

  • 'copy' problem ade 4

    'copy' problem with ade 4
    copy with edit [copy function greyed out] or manual [ctrl+c - even in right sequence] not working on ade publication 'Nuwe Testament en Psalms
    ’n Direkte Vertaling'
    the copy function does work on 'Getting Started With ADOBE DIGITAL EDITIONS 4.0', a book which is part of the program
    pc specs are more than adequate
    urgent help needed here
    thank you!
    in Christ
    gabriel

    hi dominic
    yes, i can do that with this document to
       1. with the copy function from the file tab
       2. by selecting text and right click
       3. manually with ctrl+c
    my problem is with the other publication, 'Nuwe Testament en Psalms'n
    Direkte Vertaling', there the copy option in the file tab is greyed out and
    manually it does nothing - none of the three copy methods work.
    pse see attached jpg
    from gabriël smita child of the Living God through Christ Jesus[?]
    South Africa
    *0823260759"So faith comes by hearing, and hearing by the word of Christ."
    <https://mlj-sermons-mp3-tagged.s3.amazonaws.com/Romans/3260D.mp3>Rom 10:17*
    *https://www.facebook.com/ggsmit <https://www.facebook.com/ggsmit>bugged by
    cockroaches? <http://www.ecozap.co.za>bugged by ants?
    <http://www.cockroaches.co.za/killing_ants.pdf> *

  • I have type-safe generic array copying!

    Check this out. I get no warnings from this, and so far it seems to work fine, and it only takes twice the time of a normal array copy.
    All you have to do is pass in a dummy array of the same type as your inputArray, which under normal circumstances is very doable. The dummy array does not need to have the same dimension as the input array, which lets you use this as a static method in a utility class without feeling the burning need to make it throw an exception.
    It takes advantage of Collections' type-safe toArray() method.
         public static <T> T[] copyArray(T[] inputArray, T[] targetArray)
              return arrayToList(inputArray).toArray(targetArray);
         private static <T> ArrayList<T> arrayToList(T[] inputArray)
              ArrayList<T> returnValue = new ArrayList<T>();
              for(int i = 0; i < inputArray.length; i++)
                   returnValue.add(inputArray);
              return returnValue;

    And I like my tabs, thank you.Many people consider using tabs in code to be
    amatuerish. I can't say I disagree. Tabs are
    represented as different lengths depending on the
    editor. If you are using Eclipse, you can set it to
    insert a number of space when you hit tab instead of
    inserting tabs.I like tabs because they are an abstraction of indentation levels, something you don't get with spaces (unless you use one space per level), and therefore it makes more sense to me to use them. I use editors with good tab sizes that are also adjustable. Plus, I just like them better. So there.

  • I/O errors, writing and copy problems to array.

    Folks recently I can't write to an array effectively. It is very very slow and usually stops.
    - capturing to the array = no success
    - copying from 1 array to the other = very slow/ error -36
    I ran disk utility a couple of times, it found things to repair and did so. Results above are still the same.
    RAID Admin does not say that there is anything wrong with the drives or arrays.
    G5/ 3.5 TB Xserve RAID divided into two RAID 5 arrays (1 for backing up the other)/ 10.4.6 and latest RAID firmware, utility updates.
    Please help/ advise.

    Are you using copper or optical cables? I've seen flaky behavior like this when someone ran a chair over an optical cable. The thing about optical cables is... they don't totally stop working. They just get unreliable and slow.

  • Byte Array Copy

    Hello,
    I have a problem that I have to write code to address the issue of modem disconnections while copying data. The problem is that I have to programmactially dial modems and copy programs to a remote windows based system. The issue is that I sometimes get disconnected from the remote site and loose my copy progress. I want to be able to be able to break apart an executable into chunks and copy those chunks to the remote harddrive and if I get disconnect, I will re dial the connection and pick up where I left off so that I dont loose the time that I spent already copying the file.
    I am currently using this method for copying the executables across the dial up connection but need to modify it and to be honest I dont know how. I know I should stuff the executable into some sort of byte array, get the length of that array, and copy each byte array element to the harddrive; loop through the array until the copy is complete. If disconnection or "semaphore timeout" exception is thrown, redial the connection, read the bytes that are already written on the remote locations harddrive, compare the bytes to what is stored locally, and copy those bytes until complete.
    Here is the method that I am using. I understand that I could use NIO to do the copy and it would be faster but I dont want to have to make major changes. I have attempted to search google for answers but only can find methods like this. Which is basically what I have...
        public static boolean uploadPackage(String src,String dst) {
            try {
                InputStream in = new FileInputStream(src);
                OutputStream out = new FileOutputStream(dst);
                // Transfer bytes from in to out
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) > 0) {
                    System.out.println("WRITING BUFFER " + len + " " + in.read(buf));
                    out.write(buf, 0, len);
                in.close();
                out.close();
                return true;
            } catch (IOException e) {
                System.out.println("IOEXCEPTION " + e);
                return false;
        }

    Dukes are worthless.
    Do you have a question? I didn't see one.
    Why do you feel the need to put a bunch of byte arrays to disk? The file itself is ultimately a byte array. Why not just store a file that says what the last byte successfully transferred was. Probably it should also indicate the last file modification date, so you can see if the file has changed out from under you between transfers. Then you can just reload the file and resend the bits you need.
    For that matter, there must be a system that can transfer files in bits. I used to do this with uuencode and split on shell script. I wouldn't be surprised if rsync or something like it has support for something like this.

  • Short array copy

    Hi everyone,
    I would like to know if it exits a "clean" way to copy a short array in another in Javacard API 222. I would like to avoid using a loop if possible. I know that the function for byte arrays is Util.arrayCopyNonAtomic. I tried to use the ArrayLogic.arrayCopyRepackNonAtomic function but my cards do not support the javacardx.framework.util library.
    Thank in advance for your replies
    Cheers,
    Cyril

    A loop is going to be your only option. This could be a problem if you do not want the copy to participate in the current transaction (if any) though.
    Cheers,
    Shane

  • Associative Array (Object) problems

    Here is the function i'm dealing with
    i'm reading in a delimited string and using indexed arrays to
    break them up and assign the keys and values to an associative
    array in a loop.
    i'm using variables in the loop and the array loads as
    expected in the loop
    but outside the loop, the only key is the variable name and
    the value is undefined
    this is true using dot or array notation, as well as literal
    strings for the keys
    any help is appreciated
    watchSuspendData = function (id, oldval, newval):String {
    //the incoming suspendData string is delimited by the
    semicolon;
    //newval is: firstValue=Yes;captivateKey=1
    var listSuspendData:Array = newval.split(";"); // convert it
    to a list of key/value pairs
    if (listSuspendData.length > 0){
    //line 123: listSuspendData.length is: 2
    for (i=0; i < listSuspendData.length; i++){ //for each
    key/value pair
    var keyValArray:Array = new Array();
    var myNameValue:String = listSuspendData
    //line 127: listSuspendData is: firstValue=Yes
    keyValArray = myNameValue.split("="); // split 'em on the
    equal sign
    var myKey:String = keyValArray[0];
    var myVal:String = keyValArray[1];
    //keyValArray[0] is: firstValue
    //keyValArray[1] is: Yes
    // store the key and the value in associative array
    suspendDataArray.myKey = myVal;
    trace("line 134: suspendDataArray is: " +
    suspendDataArray.myKey);
    // trace is line 134: suspendDataArray is: Yes on the first
    pass and 1 on the second
    //the below loop always returns one array key: myKey and the
    value as undefined
    for(x in suspendDataArray){
    trace("x is: " + x); //x is: myKey
    trace("the val is: " + suspendDataArray.x); //the val is:
    undefined
    } //end for
    return newval;

    on lines 12-13 i assign the key=value pair to string
    variables
    then on lines 17-18 i assign those values to the associative
    array using dot notation
    the trace seems to work there
    the problem is that when the procedure exits the for loop,
    the associative array only has one key (myKey) and no value
    (undefined)
    all the documentation i've read shows using these types of
    arrays with either non-quoted property names like:
    myAssocArray.myKey = "somevalue";
    or
    myAssocArray[myKey] = "somevalue";
    i tried assigning the key/value pairs directly from the
    indexed arrays, but the result was always undefined
    like this:
    suspendDataArray.keyValArray[0] = keyValArray[1]
    or
    suspendDataArray[keyValArray[0]] = keyValArray[1]
    i even tried building a string in the loop and trying to
    assign all the pairs at once using the curly brace
    this is pretty wierd behavior for actionscript or i'm missing
    something basic here
    thanks for looking

  • File data copying problem

    Hi,
    Im trying to copy the contents fron one file(say abc.txt) to another file(say def.txt)....Whats wrong in the below code...
    package com.home.practise.streams;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    public class CopyOneFileToAnotherFile {
         CopyOneFileToAnotherFile() throws IOException {
              File file = new File("C:\\Documents and Settings\\Harishwar\\Desktop\\abc.txt");
              try {
                   BufferedReader br = new BufferedReader(new FileReader(file));
                   FileWriter fw = new FileWriter(new File("C:\\Documents and Settings\\Harishwar\\Desktop\\def.txt"));
                   BufferedWriter bw = new BufferedWriter(fw);
                   int ch;
                   while((ch = br.read()) != -1){
                        bw.write((char)ch);
                        System.out.print((char)ch);
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args) throws IOException {
              new CopyOneFileToAnotherFile();
    }Im not getting the output inside the file "def.txt"...why so?? what might be the problem in the above code??

    Thanks for your reply, dudes...Now I got the output..But i had one small doubt..Why these java soft people didnt write flush() method in predefined streams or readers or writers( say BufferedWriter or some other output stream).Because they're buffered. If they were auto-flushed they wouldn't be buffered.
    Why they gave us a choice to write this flush() expilictly....?So that you can control when the buffer is flushed. For performance and transactional reasons.
    Why wouldn't they have written in these predefined classes(say BufferedWriter) itself?? Because then they wouldn't be buffered. So there wouldn't be any point in them existing, or at least in having those names.
    And another small doubt, when we write explicitly bw.close(), does this mean we are saying GC to collect this variable?No, it means flush and close the stream and release the associated file handle.
    Can't GC collect this variable after complete execution of this program?Of course, but it's a file writer with a local buffer, so you should close it yourself, explicitly, when you have finished writing to it, so that you know that you've flushed and closed it, so that your application doesn't proceed on a false assumption, for example so you don't print any misleading messages saying that you've written all the data when you haven't.
    If you don't want local buffering, don't use it. But then your tactic of reading and writing one character at a time is suddenly going to run several orders of magnitude more slowly. And it's still correct discipline to dispose of external resources immediately you've finished with them.

  • File copying problems

    Copying some files using the Finder results in a dialogue box error message: "The Finder cannot complete the opeeration because some data in +(file name)+ could not be read or written. (Error code -36). The same files copy without error when using SilverKeeper (v.2.0.2) backup program.
    I am also experiencing a problem when quitting SIlverKeeper. A second or so after selecting Quit, and after the program has actually quit, a system dialogue box appears saying that the program has unexpectedly quit and offering choices of Reopen, Report to Apple or Close.
    The system also seems somewhat sluggish.
    Can anyone offer suggestions?

    Hi John, At this point I think you should get Applejack...
    http://www.versiontracker.com/dyn/moreinfo/macosx/19596
    After installing, reboot holding down CMD+s, (+s), then when the DOS like prompt shows, type in...
    applejack AUTO
    Then let it do all 5 of it's things.
    At least it'll eliminate some questions if it doesn't fix it.
    The 6 things it does are...
    Correct any Disk problems.
    Repair Permissions.
    Clear out Cache Files.
    Repair/check several plist files.
    Dump the VM files for a fresh start.
    Trash old Log files.
    First reboot will be slower, sometimes 2 or 3 restarts will be required for full benefit... my guess is files relying upon other files relying upon other files!
    Disconnect the USB cable from any UPS so the system doesn't shut down in the middle of the process.

  • Copy problems

    I have a HP LaserJet M1319f MFP.  The printer seems to work fine when printing from Word, etc.  The problem is copying.  One side of the paper put out is lighter than the other.  Is it a problem I can fix?  Like a new scanner light?  Or what please?
    Tim
    This question was solved.
    View Solution.

    That is very odd that printing from word seems ok, but the scanned print from the pc also seemed to have the same issue.  Are you able to print a Demo page from the printer? 
    On the Printer press the setup button - use the left or right to highlight Reports, press OK, then highlight Demo Page and press OK.  Please post the result from this.
    This is starting to sound more like a toner low, and could be coincidence when it works.
    Thanks,
    Thanks,
    Double-U-Dee
    Don't forget to give Kudos where Kudos is Due - OR - if a Response Resolved your Issue, Click the "Accept as Solution"
    I am an HP employee, but my posts and replies are my own and do not reflect the opinion of HP.

  • HP Officejet 8610 copy problem second tray

    Hi all,
    I have purchased a HP Officejet 8610 for a couple off months.  I have 2 trays and have the following problem. If I make a copy, I want that the printer take the second tray.  I want this to set as default value.
    When I go to the startpage of the printer (EWS)  I can set that the default copy tray is tray 2. This works fine, until the printer is set off.  When I set the printer back on, the setting is back too tray 1.
    Have someone a solution?  It's very annoying because the first tray is special paper....
    Sorry for my bad english.
    Regards

    Hello there! Welcome to the forums @Timoty ,
    I read your post about how the tray selection for copies will revert back to tray one when you restart the printer.
    I could be wrong however, maybe the printer is "disconnecting" and causing the change you selected to revert back to tray one as a default. I would suggest that you assign a static IP to ensure the connection holds the connection and could help in saving your preferences when you change them in the EWS.
    Here is a link that will help you assign a static IP (Solution three): Printer Does Not Maintain Wireless Connection
    Good luck to you! Thank you for posting in the community
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • Error 36 and External Drive File Copy Problem & USB Connections

    In attempting to copy a folder with some 200G+ of files from my iMAC, with OSX 10.6.7, to an external portable WD 1Tb HD, newly formatted to HFS+ (journaled), and connected to the iMAC via a USB cable to the USB port on the iMAC keyboard, I kept getting an error message that Finder could not complete the operation as some data couild not be read or written and transfered, and gave the "Error Code -36". After some searching ont he internet for this error code I came across a host forums discussiong the error code BUT all referred to it being the result of MAC OS hidden "dot-underscore" companioned files being created when the MAC OS X file system copies or moves files to a FAT16 or FAT32 volume. This was not the situaion in my case a both drives were OS X formatted HFS+. Eventually I came across a very vague reference to the error also occuring when the cable connection with the external HD was not solid. I reconnected my external HD and attempted the file transfer again - with the same result. Eventually I decided to plug the external HD into a USB pot on the back of the iMA itself, rather than the keyboard set. Sure enough the error issue disappeared - the transfer successfully completed.
    So my question relates to the "usb connection" challenge with iMAC. the iMAC has only 4 USB ports on the back directly. I did have two desktop external HDs plugged into 2 of these USB ports at the back of the iMAC, as well as a WACOM pad device into the 3rd, and an EPSON 3880 printer into the 4th, and so was forced to employ the ports ont he keyboard for portable HD. So - what's the answer in a situation where the 4 are insufficient and it would appear that the keyboard ports seemed to be unpowered?? Any suggestions?

    It's actually a Time Machine backup drive which is formatted in Mac OS Extended (Journaled). I wish I'd copied the exact error message.
    I believe it was something to the effect of "Error 36: The file could not be copied because some of the date could be be read/written" or something along those lines. Next time it comes up I'll copy it. I have Drive Genius running with DrivePulse, but it doesn't ever seem to start.
    My biggest concern is that this is a sign that the drive is failing. When backing up, it also slows, or stops midway through and just hangs there. Though I haven't done a lot of extensive testing on that because if the drive is failing, I don't want to speed that process up any more.
    To add to the complication, there is a second external drive which Time Machine is also backing up for me. There is one particular file, the Virtual Machine file, I was trying to get off the other external drive and it produced the same problem. That's when I went into Time Machine to try and retrieve the file that way and it did the same thing. The other external drive is making some sounds, but it doesn't sound like a distinct clicking, more like a more pronounced version of the normal constipated hard-drive sound. The Time Machine drive, isn't making any obviously strange sounds at all.
    So, I can't tell whether the drives are failing or if it could actually be that particular file itself causing some strange problems.

  • Adobe Acrobat 8 copying problem

    I have tried the Acrobat HELP feature and it wasn't helpful and so
    I turn to you! Problem: When I highlight and attempt to copy a word or phrase
    from a PDF the Acrobat application hiccups and begins to shut down- this has
    only just begun happening. I then get a kindly message from my computer that
    says diagnostics are being run but in the mean time Acrobat succeeds in shutting
    down and my computer comes up with no diagnosis. Irritating to say the least.
    Have any of you  had similar issues with Acrobat -  if so how did you resolve it?  Thanks!

    Updating worked---thank you so much!

Maybe you are looking for

  • What's wrong with itunes 10.5 ??!!??

    itunes 10.5 is so slow, and always in "no response" status. I cannot sync my ipad2 with itunes... I cannot back up my ipad2! "netsh winsock reset" does not work for me... I have tried to uninstall then re-install for couple times but the issues are s

  • Missing disk in Time Capsule

    Hi, everyone. This is my first post. I bought a 500G Time Capsule April 2008 and suddenly I cannot mount my disk when my Time Machine is doing a back up. I contact my local distributor and what they told me is that Apple would replace it with a new o

  • Account suspended after receive "Skype Manager" in...

    Hi, my account was suspended after recieve 2 emails. I didn't accept any invitation but anyway the account was automatically suspended. Email - 1) You have been invited to join the Skype Manager called Photothema. This is administered by harfstvanden

  • How to Block Viewing Back Dated Data

    Dear All, Please help in the following scenario : Requirement : To Block Viewing of Back Dated Data. For Eg : from 2012-2013 we have had data, but management wanted from 2014 April 1st on wards viewing of data for 2012-2013 year should be blocked exc

  • Creating Modules using Open API

    Hi, I am trying to create Form module using Open API. What I would like to know is :- 1. How to link the source file (c++) against the Open API library (f60d2f32.lib). The c++ source file, Does it have to be .c extension ? 2. Compile the files to cre