排除apk文件中的预定义资源

排除apk文件中的预定义资源 我用Android Studio创建了一个空白项目。 然后生成apk文件,查看我可以看到的文件:在res / drawable文件夹中有许多不需要的文件,如:abc_ic_clear_holo_light.xml,abc_ic_clear.xml,以及res / drawable-mdpi-v4文件夹中有许多不需要的图像,如: abc_ab_bottom_solid_dark_holo.9.png,abc_ab_bottom_solid_light_holo.9.png。 如何删除所有文件? 如何禁用创建drawable-hdpi,drawable-mdpi-v4(因为,我使用webview来显示应用程序的ui,所以我不需要支持多屏幕与android native)

如何循环try catch语句?

你如何循环try / catch语句? 我正在制作一个使用扫描仪读取文件的程序,它正在从键盘上读取它。 所以我想要的是如果文件不存在,程序会说“这个文件不存在请再试一次”。 然后让用户键入不同的文件名。 我尝试了几种不同的方法尝试这样做但是,我的所有尝试最终导致程序崩溃。 这就是我所拥有的 try { System.out.println(“Please enter the name of the file: “); Scanner in = new Scanner(System.in); File file = new File(in.next()); Scanner scan = new Scanner(file); } catch (Exception e) { e.printStackTrace(); System.out.println(“File does not exist please try again. “); }

JUnit与Mockito,EasyMock等嘲笑

我正在尝试在我正在测试的类中模拟一个对象的方法。 例如 class ClassToTest { public doSomething () { SomeObject a = new SomeObject (); a.doSomethingElse (); } } 有没有办法模拟变量“a”的方法? 我想doSomethingElse在测试期间什么都不做。 我目前正在使用Mockito,但我对任何模拟框架持开放态度。 谢谢

使用Spring Data REST处理自定义exception(i18n)

我正在使用Spring Boot 1.5.4与Spring JPA,Spring Data REST,HATEOAS ……我正在寻找最佳实践(Spring方式)来定制exceptionSpring Data REST正在管理添加i18n支持。 我查看了类MessageException( https://github.com/spring-projects/spring-data-rest/blob/master/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest /webmvc/support/ExceptionMessage.java )作为起点。 典型的Spring Data RESTexception非常好: { “timestamp”: “2017-06-24T16:08:54.107+0000”, “status”: 500, “error”: “Internal Server Error”, “exception”: “org.springframework.dao.InvalidDataAccessApiUsageException”, “message”: “org.hibernate.TransientPropertyValueException: Not-null property references a transient value – transient instance must be saved beforeQuery current operation : com.test.server.model.workflows.WorkSession.checkPoint -> com.test.server.model.checkpoints.CheckPoint; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property […]

如何使用Epsilon的assertEquals在JUnit中断言两个双精度?

不推荐使用双精度的assertEquals。 我发现应该使用Epsilon的表格。 这是因为不可能100%严格的双打。 但无论如何我需要比较两个双打(预期和实际结果),但我不知道该怎么做。 目前我的测试看起来像: @Test public void testCalcPossibleDistancePercentageCount() { int percentage = 100; assertEquals(“Wrong max possible value for %” + percentage, 110.42, processor.calcPossibleValue(percentage)); percentage = 75; /*corresponding assertions*/ } 以下是我收到的3个双值,我想用JUnit检查:110.42,2760.5和10931.58。 JUnit测试应该如何使用断言? 我在一个方法中计算得到它们: processor.calcPossibleValue(allowed_percentage){return /*Some weird formulae here*/;}

递归generics

有没有办法使这种方法适当通用并取消警告? /** * Sort a collection by a certain “value” in its entries. This value is retrieved using * the given valueFunction which takes an entry as argument and returns * its value. * * Example: * // sort tiles by number *Collects.sortByValue(tileList, true, new Function() { * public Integer call(NormalTile t) { * return […]

如何从ContainerRequestContext获取路径参数

我想为我的REST API端点应用授权filter,并且filter需要path参数来进行过滤。 这是我的端点和代码: 终点: curl –url ‘localhost:80/reports/resources/org/12345/product/111 ‘ –request GET –header ‘Authorization: ‘ 资源代码: @Path(“/resources”) public class MyResource extends AbstractResource { … @GET @Path(“/org/{orgId}/product/{productId}”) @Produces(MediaType.APPLICATION_JSON) @RoleAuthenticated public Response getResourcesReport(@PathParam(“orgId”) String orgId, @PathParam(“productId”) String productId, @Context HttpHeaders headers){….} 过滤: @PreMatching @RoleAuthenticated public class AuthorizationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { MultivaluedMap […]

具有LEAST和GREATESTfunction的JPA CriteriaQuery

我有一个问题,我需要使用LEAST和GREATEST函数连接两个表,但使用JPA CriteriaQuery。 这是我想要复制的SQL … select * from TABLE_A a inner join TABLE_X x on ( a.COL_1 = least(x.COL_Y, x.COL_Z) and a.COL_2 = greatest(x.COL_Y, x.COL_Z) ); 我看过CriteriaBuilder.least(..)和最大的(..) ,但是我很难理解如何创建Expression以传递给任一函数。

request.getUserPrincipal()得到null

用户成功通过身份validation,但在进入下一个控制器后进行身份validation后,我获得了request.getUserPrincipal() null。 我正在使用websphere 7,我的应用程序是在spring mvc。 System.out.println(“subject.getPrincipals(): ” + subject.getPrincipals()); WSSubject.setRunAsSubject(subject); 在登录控制器中进行身份validation后,subject.getPrincipals()返回principal,但是当我转到下一个控制器时,我得到request.getUserPrincipal() null。 web.xml中 Administrator manager_Service manageservice /manageServiceList.htm Administrator CONFIDENTIAL application.xml中 Administrator IBM应用-bnd.xml 用户属于管理员组。 我的所有部署描述符都设置得很好。 知道我哪里弄错了吗?

Runtime.getRuntime()。exec(),执行Java类

我正在从我的应用程序中执行Java类。 proc = Runtime.getRuntime().exec(“java Test”); 如何识别Test是否成功执行(即没有例外)? 重定向输出/错误: proc = Runtime.getRuntime().exec(new String[] { “java”, mclass, “>NUL 2>test.txt” }); 从cmd : java Main >NUL 2>test.txt