Better regex syntax ideas

I need some help to complete my idea about regexes. Introduction There was a question about better syntax for regexes on SE, but I don't think I'd use the fluent syntax. It's surely nice for newbies, but in case of a complicated regex, you replace a line of gibberish by a whole page of slightly better gibberish. I like the approach by Martin Fowler, where a regex gets composed o

更好的正则表达式语法思想

我需要一些帮助来完成关于正则表达式的想法。 介绍 在SE上有一个关于更好的正则表达式语法的问题,但我不认为我会使用流利的语法。 对于新手来说,它确实很好,但是如果是复杂的正则表达式,你可以用一整页稍微好一点的乱码代替一行乱码。 我喜欢Martin Fowler的方法,正则表达式由小块组成。 他的解决方案是可读的,但手工制作; 他提出了一个聪明的方法来构建一个复杂的正则表达式,而不是支持它的类。 我正在尝试使

Export certificate in windows store to a p12 file using Java

I will need to export a certificate in windows store to a p12 file. Similar to what you can do from firefox/IE browser but in JAVA. The only way I am able to do it currently is doing a C# with double Cpp wrappers or MCPP with wrapper using JNI which is not really useful. I have tried using SUNMSCAPI but I was not able to.. Any inputs appreciated.. Thank you.. If the above is certainly not po

使用Java将Windows Store中的证书导出到p12文件

我将需要将Windows Store中的证书导出到p12文件。 类似于你可以从firefox / IE浏览器,但在JAVA中做什么。 目前我能做到的唯一方法是使用双Cpp包装器或使用JNI封装的MCPP来做C#,这并不是很有用。 我曾尝试使用SUNMSCAPI,但我无法..任何输入赞赏..谢谢.. 如果上述情况肯定不可行,那么是否可以使用这些证书创建密钥库? 您可以使用Java标准密钥库API和Bouncy Castle。 您可以加载名为Windows-MY的密钥库,其中包含存储

How can I close opened drivers during Selenium tests with TestNG

I have a Selenium project which runs fine on my local machine but has a problem when run by Hudson. The problem is that it doesn't close opened drivers at the end of each test. Prerequisites: This project is run by Hudson on a Selenium grid server. (I have also run it on my local machine on a Selenium grid server and the problem doesn't occur) So, I have a BeforeAndAfter class which

如何在使用TestNG的Selenium测试期间关闭打开的驱动程序

我有一个Selenium项目,它在我的本地机器上运行良好,但在由Hudson运行时出现问题。 问题是它没有在每次测试结束时关闭打开的驱动程序。 先决条件:该项目由Hudson在Selenium网格服务器上运行。 (我也在Selenium网格服务器的本地机器上运行它,并且不会出现问题) 所以,我有一个由每个测试类实现的BeforeAndAfter类。 在BeforeAnd内我有一个@BeforeClass方法,它启动一个新的驱动程序:driver = new RemoteWebDriver(

Android widget onReceive crashing

Basically when I click a particular button on the widget I want to fetch the next record in the database. The function itself works fine as I use it in the app. But in the widget it's crashing. I'm thinking it's the onReceive function itself that is the problem though as even I just set the onReceive to update a textview it crashes as nullpointerexception. public static String NE

Android小部件onReceive崩溃

基本上,当我单击小部件上的特定按钮时,我想获取数据库中的下一条记录。 该功能本身正常工作,因为我在应用程序中使用它。 但在小部件中,它正在崩溃。 我认为这是onreceive函数本身就是问题,但即使我只是设置onReceive来更新它崩溃的文本视图为nullpointerexception。 public static String NEXT_RECORD =“next_record”; 这是它被调用的地方: Intent intent = new Intent(context,MyWidgetProvider.class); in

Preference wont change in my main activity

In my MainActivity I have a textView. In that textView there is a Number that I keep in a SharedPreferences. and every couple of min The SharedPreferences is changed with an alarm manager, but the SharedPreferences in my MainActivity wont change, anyone has an idea why? this is a part of The code in the MainActivity SharedPreferences preferences = PreferenceManager.getDefaultSharedPrefer

偏好不会改变我的主要活动

在我的MainActivity中,我有一个textView。 在那个textView中有一个我保存在SharedPreferences中的Number。 和每一分钟SharedPreferences改变与警报管理器,但在我的MainActivity的SharedPreferences不会改变,任何人有一个想法,为什么? 这是MainActivity中代码的一部分 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); int ReleaseDate = preferences.getInt("com.fisher

How can I send an email by Java application using GMail, Yahoo, or Hotmail?

Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute the application. Answers with any of using Hotmail, Yahoo or GMail are acceptable. First download the JavaMail API and make sure the relevant jar files are in your classpath. Here's a fu

如何通过Java应用程序使用GMail,Yahoo或Hotmail发送电子邮件?

是否可以使用GMail帐户从我的Java应用程序发送电子邮件? 我已经使用Java应用程序配置了我的公司邮件服务器来发送电子邮件,但是当我分发应用程序时,这不会削减它。 任何使用Hotmail,Yahoo或GMail的答案都可以接受。 首先下载JavaMail API并确保相关的jar文件位于你的类路径中。 这里有一个使用GMail的完整工作示例。 import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class Main {

Drop file onto .jar and pass filename to main()

I'd like to drop a file onto my jar and have the filename passed on to my main method as argument. I'm on OSX. How can I do that? If the app. is deployed using Java Web Start, a file association can be declared. Double click any file of that type and the path of the file is supplied to the main(String[]). BTW - here is a demo. of the JNLP file API. Note well the 2nd bug report,

将文件拖放到.jar上并将文件名传递给main()

我想将一个文件放到我的jar文件中,并将文件名作为参数传递给我的main方法。 我在OSX上。 我怎样才能做到这一点? 如果应用程序。 使用Java Web Start进行部署,可以声明文件关联。 双击该类型的任何文件,并将文件的路径提供给main(String [])。 顺便说一句 - 这是一个演示。 的JNLP文件API。 请注意第二个错误报告,这意味着1.6.0_10 +的最低版本,以便不删除应用程序图标上的文件。 要在OSX上执行此操作,您可

Java Design Patterns Examples

Possible Duplicate: Examples of GoF Design Patterns for some university work I'm working on a new way (using AO) to implement design patterns. So now basically need to find some "real-life" examples of usage of design patterns (namely adapter, proxy, singleton, factory and observer) inside Java applications so to isolate the very part of the code in which the certain DP is bei

Java设计模式示例

可能重复: GoF设计模式示例 对于一些大学工作,我正在以一种新的方式(使用AO)来实现设计模式。 因此,现在基本上需要找到一些在Java应用程序中使用设计模式(即适配器,代理,单件,工厂和观察器)的“现实生活”示例,以隔离使用某个DP的代码的大部分所以试图以不同的方式实现该部分。 任何(不那么大)的Java应用程序,一块Java框架/库,github / googlecode项目都将非常值得赞赏。 看看Spring框架。 它使用了许多

What does the Java assert keyword do, and when should it be used?

为了理解断言的关键作用,一些真实的例子是什么? Assertions (by way of the assert keyword) were added in Java 1.4. They are used to verify the correctness of an invariant in the code. They should never be triggered in production code, and are indicative of a bug or misuse of a code path. They can be activated at run-time by way of the -ea option on the java command, but are not turned on by defa

Java断言关键字的作用是什么,以及何时应该使用它?

为了理解断言的关键作用,一些真实的例子是什么? 在Java 1.4中添加了断言(通过assert关键字)。 它们用于验证代码中不变量的正确性。 它们不应该在生产代码中被触发,并且指示代码路径的错误或误用。 它们可以通过java命令的-ea选项在运行时激活,但默认情况下不会打开。 一个例子: public Foo acquireFoo(int id) { Foo result = null; if (id > 50) { result = fooService.read(id); } else { result

Why is MouseAdapter an adapter?

The name (and javadocs) imply that MouseAdapter is an adapter (the design pattern). But I don't see it as such - it doesn't adapt anything to anything, at first sight at least The only adaptation that happens is that you can pass an instance of MouseAdapter to any method that expects either of the interfaces. So, you make it possible to use a MouseListener instance where only MouseMot

为什么MouseAdapter是一个适配器?

名称(和javadocs)暗示MouseAdapter是一个适配器(设计模式)。 但我不认为它是这样的 - 它至少对乍看起来什么都不适应 发生的惟一改变是您可以将MouseAdapter的实例MouseAdapter给期望任一接口的任何方法。 所以,你可以使用只有MouseMotionListener的MouseListener实例。 但是没有“翻译”发生。 它不符合GoF的UML - 在“类适配器”版本中,预计对一个方法的调用将调用来自适配器的方法。 那么,这是一个适配器(设计模