copy

How do I copy DOM nodes from one document to another in Java?

允我心安 提交于 2019-12-17 16:12:02
问题 I'm having trouble with copying nodes from one document to another one. I've used both the adoptNode and importNode methods from Node but they don't work. I've also tried appendChild but that throws an exception. I'm using Xerces. Is this not implemented there? Is there another way to do this? List<Node> nodesToCopy = ...; Document newDoc = ...; for(Node n : nodesToCopy) { // this doesn't work newDoc.adoptChild(n); // neither does this //newDoc.importNode(n, true); } 回答1: The problem is that

How to get Desktop location?

安稳与你 提交于 2019-12-17 15:46:34
问题 I'm using Python on Windows and I want a part of my script to copy a file from a certain directory (I know its path) to the Desktop. I used this: shutil.copy(txtName, '%HOMEPATH%/desktop') While txtName is the txt File's name (with full path). I get the error: IOError: [Errno 2] No such file or directory: '%HOMEPATH%/DESKTOP' Any help? I want the script to work on any computer. 回答1: You can use os.environ["HOMEPATH"] to get the path. Right now it's literally trying to find %HOMEPATH%/Desktop

Converting a row of cv::Mat to std::vector

喜欢而已 提交于 2019-12-17 15:42:34
问题 I have a fairly simple question: how to take one row of cv::Mat and get all the data in std::vector ? The cv::Mat contains doubles (it can be any simple datatype for the purpose of the question). Going through OpenCV documentation is just very confusing, unless I bookmark the page I can not find a documentation page twice by Googling, there's just to much of it and not easy to navigate. I have found the cv::Mat::at(..) to access the Matrix element, but I remember from C OpenCV that there were

Converting a row of cv::Mat to std::vector

梦想与她 提交于 2019-12-17 15:41:58
问题 I have a fairly simple question: how to take one row of cv::Mat and get all the data in std::vector ? The cv::Mat contains doubles (it can be any simple datatype for the purpose of the question). Going through OpenCV documentation is just very confusing, unless I bookmark the page I can not find a documentation page twice by Googling, there's just to much of it and not easy to navigate. I have found the cv::Mat::at(..) to access the Matrix element, but I remember from C OpenCV that there were

Copying non null-terminated unsigned char array to std::string

早过忘川 提交于 2019-12-17 10:38:20
问题 If the array was null-terminated this would be pretty straight forward: unsigned char u_array[4] = { 'a', 's', 'd', '\0' }; std::string str = reinterpret_cast<char*>(u_array); std::cout << "-> " << str << std::endl; However, I wonder what is the most appropriate way to copy a non null-terminated unsigned char array, like the following: unsigned char u_array[4] = { 'a', 's', 'd', 'f' }; into a std::string . Is there any way to do it without iterating over the unsigned char array ? Thank you

Fast way to copy dictionary in Python

纵饮孤独 提交于 2019-12-17 10:20:41
问题 I have a Python program that works with dictionaries a lot. I have to make copies of dictionaries thousands of times. I need a copy of both the keys and the associated contents. The copy will be edited and must not be linked to the original (e.g. changes in the copy must not affect the original.) Keys are Strings, Values are Integers (0/1). I currently use a simple way: newDict = oldDict.copy() Profiling my Code shows that the copy operation takes most of the time. Are there faster

How to copy a file from one directory to another using PHP?

若如初见. 提交于 2019-12-17 07:16:14
问题 Say I've got a file test.php in foo directory as well as bar . How can I replace bar/test.php with foo/test.php using PHP ? I'm on Windows XP, a cross platform solution would be great but windows preferred. 回答1: You could use the copy() function : // Will copy foo/test.php to bar/test.php // overwritting it if necessary copy('foo/test.php', 'bar/test.php'); Quoting a couple of relevant sentences from its manual page : Makes a copy of the file source to dest. If the destination file already

How to copy a file from one directory to another using PHP?

一个人想着一个人 提交于 2019-12-17 07:16:07
问题 Say I've got a file test.php in foo directory as well as bar . How can I replace bar/test.php with foo/test.php using PHP ? I'm on Windows XP, a cross platform solution would be great but windows preferred. 回答1: You could use the copy() function : // Will copy foo/test.php to bar/test.php // overwritting it if necessary copy('foo/test.php', 'bar/test.php'); Quoting a couple of relevant sentences from its manual page : Makes a copy of the file source to dest. If the destination file already

How to properly -filter multiple strings in a PowerShell copy script

元气小坏坏 提交于 2019-12-17 07:12:32
问题 I am using the PowerShell script from this answer to do a file copy. The problem arises when I want to include multiple file types using the filter. Get-ChildItem $originalPath -filter "*.htm" | ` foreach{ $targetFile = $htmPath + $_.FullName.SubString($originalPath.Length); ` New-Item -ItemType File -Path $targetFile -Force; ` Copy-Item $_.FullName -destination $targetFile } works like a dream. However, The problem arises when I want to include multiple file types using the filter. Get

Set / Copy javascript computed style from one element to another

和自甴很熟 提交于 2019-12-17 06:54:54
问题 So I am trieing to copy all the style that apply on one element ( class / id / tagName / attribute etc. ). So far I found out that I can copy the computed style of an element, Just one problem ... couldend apply it on outher element ;/ or diffrend way to copy all the style. (this is as far as i got :/ ) http://jsfiddle.net/8KdJd/2/ //queriks mode + minor changes to retrive the computed style function getCS(el) { if (el.currentStyle) var y = el.currentStyle; else if (window.getComputedStyle)