示例字符串
one thousand only
two hundred
twenty
seven
Run Code Online (Sandbox Code Playgroud)
如何更改大写字母中字符串的第一个字符而不更改任何其他字母的大小写?
改变之后应该是:
One thousand only
Two hundred
Twenty
Seven
Run Code Online (Sandbox Code Playgroud)
注意:我不想使用apache.commons.lang.WordUtils来执行此操作.
我使用执行以下代码mvn exec:java com.mycompany.FooServer.
我想添加另一个我可以执行的服务器mvn exec:java com.mycompany.BarServer.
我如何在一个pom文件中执行此操作?
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.mycompany.FooServer</mainClass>
</configuration>
</plugin>
</build>
Run Code Online (Sandbox Code Playgroud) 我使用slf4j来跟踪信息.我的代码是
private static final Logger log = LoggerFactory.getLogger(ObjectTest.class);
log.trace("Time taken to store " + count
+ " objects of size " + size + " is " + (time) + " msecs");
log.trace("Time taken to store {} objects of size {} is {} msecs",
new Object[] { count, size, time });
log.trace("Time taken to store {} objects of size {} is {} msecs",
count, size, time);
Run Code Online (Sandbox Code Playgroud)
这将是记录跟踪的首选机制.
如何在java中使用aws-sdk以编程方式启动和停止亚马逊EC2实例?
任何帮助都非常感谢,因为我花了一天时间试图解决这个问题.
我正在尝试使用restfb获取所有帖子消息,我的代码如下
public Connection<Post> publicSearchMessages(Date fromDate, Date toDate) {
Connection<Post> messages = publicFbClient.fetchConnection("search",
Post.class,
Parameter.with("q", "Watermelon"),
Parameter.with("since", fromDate),
Parameter.with("until", toDate),
Parameter.with("type", "post"));
return messages;
}
Run Code Online (Sandbox Code Playgroud)
这仅提供最新的25条帖子.
Parameter.with("limit",100)
如果我设置了limit参数,它会提供100条消息,但我不想限制提取帖子消息.所以,
无论如何,我可以获得与搜索条件匹配的完整邮件列表,而无需设置限制参数?
我正在尝试使用Java中的aws-sdk 启动Amazon EC2云计算机[startInstance][2].我的代码如下.
public String startInstance(String instanceId) throws Exception {
List<String> instanceIds = new ArrayList<String>();
instanceIds.add(instanceId);
StartInstancesRequest startRequest = new StartInstancesRequest(
instanceIds);
startRequest.setRequestCredentials(getCredentials());
StartInstancesResult startResult = ec2.startInstances(startRequest);
List<InstanceStateChange> stateChangeList = startResult
.getStartingInstances();
log.trace("Starting instance '{}':", instanceId);
// Wait for the instance to be started
return waitForTransitionCompletion(stateChangeList, "running",
instanceId);
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,我收到以下AWS错误:
Status Code: 400, AWS Request ID: e1bd4795-a609-44d1-9e80-43611e80006b, AWS Erro
r Code: InvalidInstanceID.NotFound, AWS Error Message: The instance ID 'i-2b97ac
2f' does not exist
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpCli
ent.java:538)
at …Run Code Online (Sandbox Code Playgroud) 我们一直在使用GenericEnumUserType作为可扩展的枚举,而我们的类无法在Hossnate 3.6+容器中加载JBoss 6.
抛出以下错误
#abc state=Create: java.lang.NoSuchMethodError: org.hibernate.type.Type
Factory.basic(Ljava/lang/String;)Lorg/hibernate/type/Type;
Run Code Online (Sandbox Code Playgroud)
在以下代码上
type = (NullableType)TypeFactory.basic(identifierType.getName());
Run Code Online (Sandbox Code Playgroud) 我正在尝试生成一个可以在my rails webapp移动版本之间使用的布局.我一直在使用nifty-generator,但它说生成的文件与rails3新应用程序创建生成的文件相同.
default scaffold和之间的主要区别是nifty:scaffold什么?
facebook graph api是否支持按特定位置搜索Post消息?
我使用 jedis 进行简单的键值数据存储...我的代码如下
private static final String HOST = "50.30.35.9";
private static final int PORT = 2863;
Jedis jedis = new Jedis(HOST, PORT);
try {
jedis.set("foo", "bar");
jedis.get("foo");
} catch (Exception e) {
System.err.println("Unable to connect to Redis");
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
当我使用 jedis 客户端测试 redis 服务器时,出现以下异常。
redis.clients.jedis.exceptions.JedisConnectionException:
java.net.SocketTimeoutException: connect timed out
at redis.clients.jedis.Connection.connect(Connection.java:124)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java: 54)
at redis.clients.jedis.Connection.sendCommand(Connection.java: 77)
at redis.clients.jedis.BinaryClient.set(BinaryClient.java:71)
at redis.clients.jedis.Client.set(Client.java:21)
at redis.clients.jedis.Jedis.set(Jedis.java:48)
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?