How do I copy a folder from remote to local using scp?

How do I copy a folder from remote to local host using scp? I use ssh to log in to my server. Then, I would like to copy the remote folder foo to local /home/user/Desktop. How do I achieve this? 12 scp -r [email protected]:/path/to/foo /home/user/Desktop/ By not including the trailing “https://stackoverflow.com/” at the end of … Read more

How do I copy an object in Java?

Create a copy constructor: class DummyBean { private String dummy; public DummyBean(DummyBean another) { this.dummy = another.dummy; // you can access } } Every object has also a clone method which can be used to copy the object, but don’t use it. It’s way too easy to create a class and do improper clone method. … Read more

How do I do a deep copy of a 2d array in Java?

Yes, you should iterate over 2D boolean array in order to deep copy it. Also look at java.util.Arrays#copyOf methods if you are on Java 6. I would suggest the next code for Java 6: public static boolean[][] deepCopy(boolean[][] original) { if (original == null) { return null; } final boolean[][] result = new boolean[original.length][]; for (int i … Read more

Java Copy Constructor ArrayLists

Note: Cloning the lists, isn’t the same as cloning the elements in the list. None of these approaches work the way you want them to: //1 people = new ArrayList<Cool>(other.people); //2 people = new ArrayList<Cool>(); for(Cool p : other.people) { people.add(p); } The approaches above will fill people such that it contains the same elements as other.people. However, … Read more