在Android中检查密码

我想检查密码,我在Android中有一个密码字段 package com.example.berk4; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; public class MainActivity extends Activity implements OnClickListener{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EditText et = (EditText)findViewById(R.id.editText1); Button buttonEnter = (Button)findViewById(R.id.button1); buttonEnter.setOnClickListener(this); } @Override public void onClick(View v) { EditText et = (EditText)findViewById(R.id.editText1); String […]

递归和返回关键字

我目前正在学习Java教程,现在正在使用Recursions。 我有以下代码来计算传递给阶乘方法的任何数字的阶乘 public class App { public static void main(String[] args) { //Eg 4! = 4*3*2*1(factorial 4) System.out.println(factorial(4)); } private static int factorial(int value){ //System.out.println(value); if (value == 1){ return 1; } return factorial(value – 1)*value; } } 我无法理解这部分内容 if (value == 1){ return 1; } return factorial(value – 1)*value; 我的理解是return关键字只是终止方法,和/或返回方法声明的相同类型的值(即int,String等)。 运行以下行时会发生什么? return factorial(value – […]

如何将curl -X post翻译成java

我试图将curl命令转换为Java(使用Apache HttpClient 4.x): export APPLICATION_ID=SOME_ID export REST_API_KEY=SOME_KEY curl -i -X POST \ -H “X-Parse-Application-Id: ${APPLICATION_ID}” \ -H “X-Parse-REST-API-Key: ${REST_API_KEY}” \ -H “Content-Type: image/png” \ –data-binary @/Users/thomas/Desktop/greep-small.png \ https://api.parse.com/1/files/greep.png 但是我收到以下错误:{“error”:“unauthorized”}。 这就是我的java代码: DefaultHttpClient httpclient = new DefaultHttpClient(); HttpHost targetHost = new HttpHost(“localhost”, 80, “http”); httpclient.getCredentialsProvider().setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials(“username”, “password”)); HttpPost httpPost = new HttpPost(“https://api.parse.com/1/files/greep.png”); System.out.println(“executing […]

用于在grails中列出的“addAll()”的语法?

在java中,如果我有一个列表,我可以使用addAll(otherList); 将一个列表中的所有元素添加到另一个列表中。 什么是grails中的等价物? 我有一个具有hasMany关系的Domain对象。 要添加它,我会使用类似的东西 Object.addToMyList(someitem); 而它似乎 Object.addAllToMyList(otherList) 不存在。 什么是grails中的等价物?

如何结合Spring Security和js sockjs-client

我想通过sockjs-client创建一个Spring Server和一个Broswer javascript客户端连接。 应通过Spring Security确保连接。 我有以下两难困境: Spring Security似乎假设websocket握手是通过经过身份validation的http会话发生的(例如,JSESSIONID cookie设置,登录发生)。 然而,sockjs-client似乎对开发人员施加限制,即必须使用未经过身份validation的http会话(请参阅https://github.com/sockjs/sockjs-client/issues/196 ),以任何方式强制执行此操作。 我对这种困境的评价是否正确,是否有任何明显的解决方案来实现带有websockets的弹簧服务器的安全性,以便sockjs-client可以安全地连接? 如果用于创建经过身份validation的HttpSession,建议的在GET / info请求中传递任何身份validation令牌的解决方案看起来像是无法绕过SockJS安全限制。 这似乎是几个人问题的基础,例如: 在使用sockjs和stomp的/ info请求期间没有cookie Spring Websocket + SockJS的身份validation模型,并按用户发送消息 如何从Spring 4 stomp websocket方法获取/设置主体和会话属性 https://stackoverflow.com/questions/33156282 Spring Websockets @SendToUser没有登录? Spring Session Basic Auth令牌作为Spring-Websocket中的查询参数传递 Spring安全websocket和HTTP身份validation/授权 Spring Session,Websocket Security集成流程 Spring安全/ Spring会话/ Web套接字 Spring Boot,Websockets无法从Session获取用户(即java.security.Principal) Spring 4 WebSockect over STOMP Authentication http://sunitkatkar.blogspot.de/2014/01/spring-4-websockets-with-sockjs-stomp.html 我看到3种可选方式: 不要使用SockJs,而只使用本机Websockets 通过query-param Token在经过身份validation的Http Session上使用SockJS,并牺牲一些安全性 […]

Android:如何从这个json获取JSON对象键:

这是JSON数组: { “server_response”: [{ “Total”: “135”, “Paid”: “105”, “Rest”: “30” }] } 那么,我怎样才能获得对象名称? 我想把它们放在单独的TextView中。 谢谢。

从Eclipse在AWS-EMR上运行MapReduce作业

我在Eclipse中有WordCount MapReduce示例。 我将它导出到Jar,并将其复制到S3。 然后我在AWS-EMR上运行它。 成功。 然后,我阅读了这篇文章 – http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-common-programming-sample.html它展示了如何使用AWS-EMR Api来运行MapReduce作业。 它仍假设您的MapReduce代码打包在Jar中。 我想知道是否有一种方法可以直接在AWS-EMR上从Eclipse运行MapReduce代码,而无需将其导出到Jar。

如何监控文件上传进度?

我需要将文件上传到服务器并监视它的进度。 我需要通知每次发送多少字节。 例如,在下载的情况下,我有: HttpURLConnection connection = (HttpURLConnection) m_url.openConnection(); connection.connect(); InputStream stream = connection.getInputStream(); while ((currentBytes = stream.read(byteBuffer)) > 0) { totalBytes+=currentBytes; //calculate something… } 现在我需要为上传做同样的事情。 但如果使用 OutputStreamWriter stream = new OutputStreamWriter(connection.getOutputStream()); stream.write(str); stream.flush(); 我得不到任何进程通知,关于发送了多少字节(看起来像自动操作)。 有什么建议么? 谢谢

扩展的Ascii在控制台中不起作用!

例如System.out.println(“╚”); 显示为?,同样适用于System.out.println(“\ u255a”); 为什么这不起作用? Stdout确实支持这些角色所以我不明白。

优化BerkeleyDB JE数据库

我计划在BerkeleyDB JE数据库中插入大量唯一键(~3E9)。 键将具有固定长度(~10个字节),但值将具有可变长度。 数据库不是事务性的。 您会为EnvironmentConfig和DatabaseConfig建议哪些参数来优化数据库的大小和速度? 非常感谢, 皮埃尔