runtime

How to rename a file on sdcard with Android application?

家住魔仙堡 提交于 2019-12-17 06:43:18
问题 In my Android application, I want to rename the file name at runtime. How can I do it? This is my code: String[] command = {" mv", "sun moon.jpg"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo(File f) method but it does not work. 回答1: I would recommend using File.renameTo() rather than running the mv command, since I'm fairly sure the latter isn't supported..

Change custom attribute's parameter at runtime

∥☆過路亽.° 提交于 2019-12-17 06:17:35
问题 I need change attribute’s paramater during runtime. I simplified my problem to simple example. Attribute class: [AttributeUsage(AttributeTargets.Property)] public class MyAttribute : Attribute { public string Name { get; set; } } Simple entity wich has decorated properties with attributes: public class MyEntity { [MyAttribute(Name="OldValue1")] public string Data1{ get; set; } [MyAttribute(Name = "OldValue2")] public string Data2 { get; set; } } I created instace of class MyEntity. I can

Hyperledger Fabric make: *** No rule to make target问题

寵の児 提交于 2019-12-17 04:27:56
Hyperledger Fabric make: *** No rule to make target问题 最近一段时间,改Fabric代码,发现没法编译了!make总是报找不到target! ➜ fabric git: ( master ) ✗ make configtxgen make: *** No rule to make target ` .build/bin/configtxgen', needed by ` configtxgen' . Stop. make 输出debug信息,没有error,只是告诉必须重新make ➜ fabric git: ( master ) ✗ make configtxgen -d .. . Must remake target ` .build/bin/configtxgen'. make: *** No rule to make target ` .build/bin/configtxgen ', needed by `configtxgen' . Stop. ➜ fabric git: ( master ) ✗ 后来,在其他机器上发现,存在.build文件的可以通过编译。 从对应版本的项目中复制fabric/.build过来,就可以编译了。 ➜ fabric git: ( master ) ✗ cp .. /fabric-dev/

Create JPA EntityManager without persistence.xml configuration file

馋奶兔 提交于 2019-12-17 03:46:21
问题 Is there a way to initialize the EntityManager without a persistence unit defined? Can you give all the required properties to create an entity manager? I need to create the EntityManager from the user's specified values at runtime. Updating the persistence.xml and recompiling is not an option. Any idea on how to do this is more than welcomed! 回答1: Is there a way to initialize the EntityManager without a persistence unit defined? You should define at least one persistence unit in the

Setting JVM heap size at runtime

妖精的绣舞 提交于 2019-12-17 03:07:19
问题 Is there a way to set heap size from a running Java program? 回答1: No. What you can do with an app that has very variable heap requirements is to set your max heap size very high with -Xmx and tune -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio so that the app will not hang on to a lot of memory when the heap shrinks (it does that with default settings). But note that this may cause performance problems when the memory actually used by the app varies both strongly and quickly - in that case you

【Leetcode 做题学算法周刊】第六期

好久不见. 提交于 2019-12-15 17:27:17
首发于微信公众号《前端成长记》,写于 2019.12.15 背景 本文记录刷题过程中的整个思考过程,以供参考。主要内容涵盖: 题目分析设想 编写代码验证 查阅他人解法 思考总结 目录 110.平衡二叉树 111.二叉树的最小深度 112.路径总和 118.杨辉三角 119.杨辉三角Ⅱ Easy 110.平衡二叉树 题目地址 题目描述 给定一个二叉树,判断它是否是高度平衡的二叉树。 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1。 示例 1: 给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 返回 true 。 示例 2: 给定二叉树 [1,2,2,3,3,null,null,4,4] 1 / \ 2 2 / \ 3 3 / \ 4 4 返回 false 。 题目分析设想 我们上一期做过通过遍历求二叉树的最大深度的题目,这题最粗暴的一个方案就是计算出每个子树的最大深度做高度判断,很明显,这个效率低下。我们可以通过改成自底而上的方案,当中间过程不符合,则可以跳出计算。 编写代码验证 Ⅰ.计算子树最大深度做判断 代码: /** * @param {TreeNode} root * @return {boolean} */ var isBalanced = function(root) {

Java的多进程运行模式分析

别说谁变了你拦得住时间么 提交于 2019-12-14 16:32:24
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一般我们在java中运行其它类中的方法时,无论是静态调用,还是动态调用,都是在当前的进程中执行的,也就是说,只有一个java虚拟机实例在运行。而 有的时候,我们需要通过java代码启动多个java子进程。这样做虽然占用了一些系统资源,但会使程序更加稳定,因为新启动的程序是在不同的虚拟机进程 中运行的,如果有一个进程发生异常,并不影响其它的子进程。 在Java中我们可以使用两种方法来实现这种要求。最简单的方法就是通过 Runtime中的exec方法执行java classname。如果执行成功,这个方法返回一个Process对象,如果执行失败,将抛出一个IOException错误。下面让我们来看一个简单 的例子。 // Test1.java文件 import java.io.*; public class Test { public static void main(String[] args) { FileOutputStream fOut = new FileOutputStream("c:\\Test1.txt"); fOut.close(); System.out.println("被调用成功!"); } } // Test_Exec.java public class Test_Exec {

regeneratorRuntime is not defined

試著忘記壹切 提交于 2019-12-14 05:55:46
.babelrc 文件 { "plugins": [ "@babel/plugin-proposal-optional-chaining", "@babel/plugin-transform-runtime" ], "presets": [ ["@babel/preset-env", { "useBuiltIns": "usage", "corejs": 3, "targets": { // https://jamie.build/last-2-versions "browsers": ["> 0.25%", "not ie 11", "not op_mini all"] } }] ] } npm install @babel/plugin-proposal-optional-chaining --save-dev npm install @babel/plugin-transform-runtime --save-dev Can't resolve '@babel/runtime/helpers/classCallCheck' 错误 npm i @babel/runtime --save-dev 来源: CSDN 作者: 弓弧名家_玄真君 链接: https://blog.csdn.net/txl910514/article/details/103493325

is it possible to load EF metadata at runtime?

杀马特。学长 韩版系。学妹 提交于 2019-12-14 03:58:40
问题 I want to load EF metadata from database at runtime. Is that scenario possible? First get the data from database, then write it to .ssdl, .msl and .csdl files sounds ok. But how to tell EF to use what I've loaded? Do I need to compile it or something like that? 回答1: Yes, you can do that. New up a MetadataWorkspace using the constructor which takes these files. Then you can new up an EntityConnection passing the MetadataWorkspace to the overloaded constructor, and finally new the ObjectContext

How does type stability make Julia so fast?

时光总嘲笑我的痴心妄想 提交于 2019-12-14 03:58:25
问题 I've heard that type stability is what makes Julia so fast, while still being as expressive as other interpreted languages such as Python. 回答1: Type stability allows the compiler to determine the output types of a function directly from the input types at compile time. Because Julia specializes the compilation on every input type, this means that if all functions are type stable, the compiler can deduce the types of every value inside of a function call. When this occurs, Julia's JIT compiler