copy

Managing file uploads in JSP/Servlets

余生颓废 提交于 2019-12-19 04:23:21
问题 Once again a very beginner-ish question, but here I go: I would like to use a servlet or similar to copy an uploaded file (from an html file select) to a permanent location. This is all I need to do with the file. I am currently going with using the Apache Commons FileUpload and IO libraries. Is there no easier or more elegant solution? 回答1: The Apache commons FileUpload is probably the best way if you are using pure JSP and servlets. If you use a framework like struts2 you will have some

Copying specific files to a new folder, while maintaining the original subdirectory tree

喜你入骨 提交于 2019-12-19 04:04:34
问题 I have a large directory with many subdirectories that I am trying to sort, I am trying to copy specific file types to a new folder, but I want to maintain the original subdirectories. def copyFile(src, dest): try: shutil.copy(src,dest) except shutil.Error as e: print('Error: %s' % e) except IOError as e: print('Error: %s' % s.strerror) for root, directories, files in os.walk(directory): for directoryname in directories: dirpath = os.path.join(root,directoryname) dir_paths.append(dirpath) dir

Copy file from the internal to the external storage in Android

不打扰是莪最后的温柔 提交于 2019-12-19 02:54:56
问题 My app ( Android API 15 ) makes a picture and stores it in the internal memory's folder. Now, I want to copy this file to another folder inside of the external storage, e.g. /sdcard/myapp . I tried the following approaches: Approach #1: private void copyFile(File src, File dst) throws IOException { File from = new File(src.getPath()); File to = new File(dst.getPath()); from.renameTo(to); } Approach #2: private void copyFile(File src, File dst) throws IOException { FileChannel inChannel = null

How to store persistent handles in V8?

久未见 提交于 2019-12-19 02:05:18
问题 I want my class to hold a v8::Context and a v8::External as members. Therefore, I thought I had to use persistent handles. class ScriptHelper { public: ScriptHelper(v8::Persistent<v8::Context> Context) : context(Context) { // ... } // ... private: v8::Persistent<v8::Context> context; v8::Persistent<v8::External> external; }; However, persistent handles are non copyable in V8, so the code does not compile. The error occurs in the lines where the two memberes get initialized. For the context,

Copy all treeView parent and children to another treeView c# WinForms

时间秒杀一切 提交于 2019-12-18 22:34:25
问题 I am trying to copy the entire tree (exactly all nodes) of a treeview (completely) to another treeview using this code: TreeNodeCollection myTreeNodeCollection = treeView1.Nodes; TreeNode[] myTreeNodeArray = new TreeNode[treeView1.Nodes.Count]; treeView1.Nodes.CopyTo(myTreeNodeArray, 0); treeView2.Nodes.AddRange(myTreeNodeArray); But this does not allow me to do so, it asks to either delete the nodes in source treeview or use it Clone! How can I do that? I dont want my source treeview to lose

Copy all treeView parent and children to another treeView c# WinForms

妖精的绣舞 提交于 2019-12-18 22:33:35
问题 I am trying to copy the entire tree (exactly all nodes) of a treeview (completely) to another treeview using this code: TreeNodeCollection myTreeNodeCollection = treeView1.Nodes; TreeNode[] myTreeNodeArray = new TreeNode[treeView1.Nodes.Count]; treeView1.Nodes.CopyTo(myTreeNodeArray, 0); treeView2.Nodes.AddRange(myTreeNodeArray); But this does not allow me to do so, it asks to either delete the nodes in source treeview or use it Clone! How can I do that? I dont want my source treeview to lose

Kotlin data class copy method not deep copying all members

三世轮回 提交于 2019-12-18 19:07:18
问题 Could someone explain how exactly the copy method for Kotlin data classes work? It seems like for some members, a (deep) copy is not actually created and the references are still to the original. fun test() { val bar = Bar(0) val foo = Foo(5, bar, mutableListOf(1, 2, 3)) println("foo : $foo") val barCopy = bar.copy() val fooCopy = foo.copy() foo.a = 10 bar.x = 2 foo.list.add(4) println("foo : $foo") println("fooCopy: $fooCopy") println("barCopy: $barCopy") } data class Foo(var a: Int, val bar

Create an array with n copies of the same value/object?

…衆ロ難τιáo~ 提交于 2019-12-18 19:06:15
问题 I want to create an array of size n with the same value at every index in the array. What's the best way to do this in Java? For example, if n is 5 and the value is the boolean false , the array should be: = [false, false, false, false, false] 回答1: You can try it with: boolean[] array = new boolean[5]; Arrays.fill(array, false); Second method with manual array fill: boolean[] array = new boolean[] {false, false, false, false, false}; 回答2: List<Integer> copies = Collections.nCopies(copiesCount

Why would shutil.copy() raise a permission exception when cp doesn't?

…衆ロ難τιáo~ 提交于 2019-12-18 18:36:49
问题 shutil.copy() is raising a permissions error: Traceback (most recent call last): File "copy-test.py", line 3, in <module> shutil.copy('src/images/ajax-loader-000000-e3e3e3.gif', 'bin/styles/blacktie/images') File "/usr/lib/python2.7/shutil.py", line 118, in copy copymode(src, dst) File "/usr/lib/python2.7/shutil.py", line 91, in copymode os.chmod(dst, mode) OSError: [Errno 1] Operation not permitted: 'bin/styles/blacktie/images/ajax-loader-000000-e3e3e3.gif' copy-test.py: import shutil shutil

Error: An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll

南笙酒味 提交于 2019-12-18 16:56:08
问题 This is the part that crashes and gives me this error is when I try to copy a file to a certain location. string startupDirectory = "C:\\Users\\Tyler\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"; File.Copy(startupDirectory, "Startup.exe"); I have read online and tried administrator rights and have created an "app.manifest" file: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <requestedExecutionLevel level="highestAvailable" uiAccess="false"