我正在尝试在Eclipse上使用Java 开始使用Http Client,但IDE抱怨库缺失了.
特别是我正在尝试编译这个例子但是eclipse抱怨导入声明指向一个未知库...
有人能指点我一个关于如何在eclipse上安装apache库的教程吗?
我试图下载源代码或二进制文件并将它们添加到路径中但没有用... thanx:D
我想在我的Android项目中使用Apache Commons Lang,但我不知道该怎么做.我应该使用源码还是二进制文件?如何在Eclipse中继续?
我需要知道EmbeddedSolrServer和CommonsHttpSolrServer之间的性能.
EmbeddedSolrServer:
File home = new File("C:\\workspace\\SolrWithMultipleCore\\solr");
File f = new File( home, "solr.xml" );
CoreContainer container = new CoreContainer();
container.load( "C:\\workspace\\SolrMultipleCore\\solr", f );
EmbeddedSolrServer server = new EmbeddedSolrServer( container,"core1");
EmbeddedSolrServer server1 = new EmbeddedSolrServer( container,"core2");
String query=params.getParams("q");
String query1=params.getParams("q1");
SolrQuery solrquery=new SolrQuery(query);
QueryResponse rsp1 = server.query(solrquery);
QueryResponse rsp2 = server1.query(solrquery);
Run Code Online (Sandbox Code Playgroud)
CommonsHttpSolrServer:
SolrServer httpServer = new CommonsHttpSolrServer(url);
QueryResponse rsp1=httpServer.query(q);
SolrServer httpServer1 = new CommonsHttpSolrServer(url1);
QueryResponse rsp2=httpServer1.query(q1);
Run Code Online (Sandbox Code Playgroud)
哪个是最好的EmbeddedSolrServer或CommonsHttpSolrServer?我所说的两个核心有不同的架构.我需要知道什么是MultiThreadedHttpConnectionManager.
我想知道是否有其他项目为Java提供Java库项目.我从它那里得到了一些有用的东西,比如Logging,ConnectionPool,Configurations等,但也许有些东西它不会涵盖.
目前,我不需要任何具体的东西,但只想知道是否有类似的项目.我想知道这一点,因为我可以把时间浪费在已经完成的事情上.
我正在实现一个像这样工作的软件:
我有一台运行vt100终端应用程序的Linux服务器输出文本.我的程序telnet服务器并读取/解析文本的位到相关数据.相关数据被发送到由Web服务器运行的小客户端,该Web服务器在HTML页面上输出数据.
我的问题是某些特殊字符如"åäö"被输出为问号(经典).
背景:
我的程序使用Apache Commons TelnetClient读取字节流.字节流被转换为字符串,然后相关的位被子字符串,并返回到分隔符字符.在此之后,新字符串将转换回字节数组,并使用Socket发送到Web服务器运行的客户端.此客户端根据接收的字节创建一个字符串,并将其打印在标准输出上,Web服务器从中读取并输出HTML.
第1步:byte [] - > String - > byte [] - > [发送到客户端]
Step2:byte [] - > String - > [print output]
问题:
当我在Windows上运行我的Java程序时,所有字符(包括"åäö")都会在生成的HTML页面上正确输出.但是,如果我在Linux上运行程序,所有特殊字符都会转换为" ? "(问号).
Web服务器和客户端当前正在Windows上运行(步骤2).
代码:
程序基本上是这样的:
我的节目:
byte[] data = telnetClient.readData() // Assume method works and returns a byte[] array of text.
// I have my reasons to append the characters one at a time using a StringBuffer.
StringBuffer buf = new StringBuffer();
for (byte b : …Run Code Online (Sandbox Code Playgroud) 我想我在尝试安装Apache Commons时搞砸了我的Eclipse安装......
它显示出这样的可怕事情,对于做什么没什么帮助......


奇怪的是,除了commons-lang3-3.1.jar用我正在使用的所有其他罐子复制到文件夹之外,我没有做任何事情......
我可能做了什么,我怎么可能解决这个问题?请帮忙
如何找到使用Apache类中定义的所有可用接口BeanUtils,MethodUtils等等?
public class MyClass() {
.....
public interface Interface1{};
public interface Interface2{};
}
Run Code Online (Sandbox Code Playgroud) 我无法将字符串“ 2014年4月16日17:00”解析为字符串。我试图DateUtils在apachecommons图书馆中使用。这是测试代码,除了
package com.buraktas;
import java.text.ParseException;
import java.util.Date;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;
public class ParseDateTest {
@Test
public void test() throws ParseException {
String date = "18 Apr 2014 20:00";
Date parseDate = DateUtils.parseDate(date, "dd MMM yyyy HH:mm");
System.out.println(parseDate);
}
}
Run Code Online (Sandbox Code Playgroud)
和堆栈跟踪如下所示;
java.text.ParseException: Unable to parse the date: 18 Apr 2014 20:00
at org.apache.commons.lang3.time.DateUtils.parseDateWithLeniency(DateUtils.java:391)
at org.apache.commons.lang3.time.DateUtils.parseDate(DateUtils.java:291)
at org.apache.commons.lang3.time.DateUtils.parseDate(DateUtils.java:268)
at com.buraktas.ParseDateTest.test(ParseDateTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) …Run Code Online (Sandbox Code Playgroud) Apache Commons IO 有一个方法可以将文件移动到另一个目录,这个目录不允许我在目标目录中为它指定一个新名称:
public static void moveFileToDirectory(File srcFile, File destDir, boolean createDestDir)
throws IOException
Run Code Online (Sandbox Code Playgroud)
我不想先重命名该文件,然后将该文件移动到另一个目录.有没有办法通过任何库方法中的单个语句来执行此操作?(我想要一个单一的方法,以避免任何并发问题,这将由库自动处理)
我有一定的编程经验,但是对Maven来说还很陌生。在我的最新项目中,我正在使用Apache Commons API(配置,cli等)。它可以编译,但是在运行时抛出NoSuchMethod-exception。
我的依赖关系如下所示:
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是发生错误的方法:
private Configuration parseConfig(String path) {
File configFile = new File(path);
if(!configFile.exists() || configFile.isDirectory()) {
// Error config file path invalid
CustomLogger.warn("ERROR file not found");
}
Configurations configs = new Configurations();
Configuration config = null;
try {
config = configs.properties(configFile);
}
catch (ConfigurationException cex) {
// Something went wrong
CustomLogger.warn("Config Exception");
cex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return …Run Code Online (Sandbox Code Playgroud)