我是编写RDF模式的初学者,并且想知道我应该如何充分利用URI概念并创建一个简单感兴趣的RDF文档.我正在尝试创建以下声明的RDF-
Jeffy is a Graduate student
Jeffy likes yoga
Jeffy is seeking Tennis.
Run Code Online (Sandbox Code Playgroud)
我该如何根据这三个句子编写RDF.对此有任何启发都会非常有帮助.
目前我正在从资源流加载属性文件,如下所示 -
prop.load(LoadTest.class.getClassLoader().getResourceAsStream("database.properties"));
Run Code Online (Sandbox Code Playgroud)
但我正在寻找的是,如果有任何方法,我可以从任何外部目录加载属性文件.假设我的database.properties文件在 -
C:\logging-test\database.properties
那么如何从该位置加载上述属性文件?有什么想法吗?
我在运行Windows 7的本地开发盒中安装了单节点集群,它运行正常.由于某种原因,我需要重新启动我的桌面,然后在命令提示符下这样做的时候,它总是给我以下例外 -
S:\Apache Cassandra\apache-cassandra-1.2.3\bin>cassandra -f
Starting Cassandra Server
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7199; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
Run Code Online (Sandbox Code Playgroud)
在某处使用意义端口.我在cassandra.yaml文件中做了一些更改,所以我需要关闭Cassandra server然后再重新启动它.
任何人都可以帮我吗?
谢谢您的帮助.
我试图用Java读取整个XML文件.以下是我的XML文件 -
<?xml version="1.0" encoding="UTF-8"?>
<app hash='nv', name='Tech', package = '1.0', version='13', filesize='200', create_date='01-03-1987', upate_date='07-09-2013' >
<url>
<name>RJ</name>
<score>10</score>
</url>
<url>
<name>ABC</name>
<score>20</score>
</url>
</app>
Run Code Online (Sandbox Code Playgroud)
下面是我的代码,我用来读取如上所示的完整XML文件,然后从该XML文件中获取哈希,名称,包等值.
public static void main(String[] args) {
try {
File fXmlFile = new File("C:\\ResourceFile\\app.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
System.out.println(doc);
} catch (Exception e) {
}
}
Run Code Online (Sandbox Code Playgroud)
一旦我运行上述程序.我总是得到以下的兴奋 -
[Fatal Error] app.xml:2:22: Element type "app" must be followed by either attribute specifications, ">" or "/>".
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?
这段代码出了什么问题...我正在尝试解析pdf文件并从中提取文本...但是对于某些pdf我能够提取文本...而对于一些它会抛出错误
Invalid dictionary, found: '' but expected: '/'
org.apache.tika.exception.TikaException: Unexpected RuntimeException from org.apache.tika.parser.pdf.PDFParser@67fb878
Run Code Online (Sandbox Code Playgroud)
这是我的代码.. !! ByteArray的一些问题??
private BinaryParser binaryParser;
binaryParser.parse(page.getBinaryData());
public void parse(byte[] data) {
InputStream is = null;
try {
is = new ByteArrayInputStream(data);
text = null;
Metadata md = new Metadata();
metaData = new HashMap<String, String>();
text = tika.parseToString(is, md).trim();
processMetaData(md);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
private void processMetaData(Metadata md){
if ((getMetaData() == null) || (!getMetaData().isEmpty())) {
setMetaData(new HashMap<String, String>()); …Run Code Online (Sandbox Code Playgroud) 我有一个A,B,C的char数组,我想打印输出为:
A,B,C,AB,AC,BC,ABC
任何建议将不胜感激......
public class CharArray {
public static void main(String[] args) {
char alpha[] = {'A', 'B', 'C'};
for(char s : alpha) {
//what to do now
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在对我的 Spring MVC 控制器方法进行单元测试。下面是我尝试进行单元测试的方法,因为它在我启动服务器时工作正常。
每当我点击index页面时,它都会在浏览器上显示三个文本框,我在其中输入数据并按下提交按钮,然后调用以addNewServers正确的值进行。
现在我需要对同样的事情进行单元测试:
@RequestMapping(value = "/index", method = RequestMethod.GET)
public Map<String, String> addNewServer() {
final Map<String, String> model = new LinkedHashMap<String, String>();
return model;
}
@RequestMapping(value = "/index", method = RequestMethod.POST)
public Map<String, String> addNewServers(@RequestParam String[] servers, @RequestParam String[] address,
@RequestParam String[] names) {
}
Run Code Online (Sandbox Code Playgroud)
下面是我的junit类:
private MockMvc mockMvc;
@Before
public void setup() throws Exception {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
this.mockMvc = standaloneSetup(new Controller()).setViewResolvers(viewResolver).build();
}
@Test
public void test04_newServers() throws …Run Code Online (Sandbox Code Playgroud) 我不知道突然发生了什么.我重新启动了我的Idea工作区,它弹出以下错误:
无法转换项目:C:\ workspace_IntelliJ\Main \new-webapp.idea\workspace.xml:第1行出错:prolog中不允许使用内容.
这个错误是什么意思?我检查了我的workspace.xml.每当我尝试在编辑器中打开它时,它会显示以下内容(我相信它已被破坏):
nulnulnul
Run Code Online (Sandbox Code Playgroud)
我不知道要改变什么以及如何解决这个问题.任何有关这方面的帮助都会很棒!
我正在对HashMap插入进行一些性能测试.我正在测试的操作是在插入后插入,读取和在内存中的大小.
我可以做,插入和读取测试,但不知道如何找出size in memory after insertion-
我有一个文本文件,其中包含200万个英文单词,其频率为此格式 -
hello 100
world 5000
good 2000
bad 9000
...
Run Code Online (Sandbox Code Playgroud)
现在我逐行读取此文件并将其存储,HashMap以便我可以使用以下代码测量插入性能.
Map<String, String> wordTest = new HashMap<String, String>();
try {
fis = new FileInputStream(FILE_LOCATION);
reader = new BufferedReader(new InputStreamReader(fis));
String line = reader.readLine();
long startTime = System.nanoTime();
while (line != null) {
String[] splitString = line.split("\\s+");
// now put it in HashMap as key value pair
wordTest.put(splitString[0].toLowerCase().trim(), splitString[1].trim());
line = reader.readLine();
}
long endTime = System.nanoTime() - startTime;
System.out.println("Insertion …Run Code Online (Sandbox Code Playgroud) 我在我的一个项目中使用RestTemplate及其工厂HttpComponentsClientHttpRequestFactory。在这个项目中,我需要对我的服务器进行 Http url 调用,该服务器正在运行一个 Restful 服务,该服务将响应作为 JSON 字符串返回。
下面是我的代码 -
public class GetUserClientData {
public String getData(KeyHolder keys) {
return new HTTPRequestAccess(keys).makeHttpRequest();
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的类,它包装了 HttpClient 部分 -
public class HTTPRequestAccess {
// should this be static?
private RestTemplate restTemplate;
private KeyHolder keys;
private int timeout;
public HTTPRequestAccess(KeyHolder keys){
this(keys.getTimeoutValue()); // setting timeout to RestTemplate
this.keys = keys;
}
public HTTPRequestAccess(int timeout) {
this.timeout = timeout;
restTemplate = new RestTemplate(clientHttpRequestFactory());
}
private ClientHttpRequestFactory clientHttpRequestFactory() {
// …Run Code Online (Sandbox Code Playgroud) java ×8
spring ×2
xml ×2
apache-tika ×1
cassandra ×1
file ×1
foaf ×1
hashmap ×1
ide ×1
junit ×1
owl ×1
parsing ×1
port ×1
properties ×1
rdf ×1
rdfs ×1
resttemplate ×1
shutdown ×1
spring-mvc ×1
string ×1