I am writing a Java program that creates some text data that I want to store as a 'raw' document in a database.
In the JavaDocs for the Store command () it states for the constructor public Store(java.lang.String path):
Since the input is not a file, but rather an InputStream of data in memory, I do indeed call setInput. However, I cannot
get this to work. Am I doing something wrong? Must the input only be from a file (and not from data in memory)?
Here is snippet of code and thanks in advance. Note: Using the client/server mode.
ClientSession session = new ClientSession(host, port, user, pwd);
session.open("MyDb");
String theData = someFunctionThatReturnsALargeStringOfData();
ByteArrayInputStream bais = new ByteArrayInputStream(theData.getBytes());
Store cmd = new Store("newFile.txt");
cmd.setInput(bais);
session.execute(cmd);
session.close();
Note sure if this helps, but this is the stack trace I get.
org.basex.core.BaseXException: Stopped at , 1/63:
Syntax: STORE (TO [path]) [input]
Store raw data.
Stores raw data to the specified [path].
at org.basex.api.client.ClientSession.receive(ClientSession.java:193)
at org.basex.api.client.ClientSession.execute(ClientSession.java:162)
at org.basex.api.client.ClientSession.execute(ClientSession.java:167)
at org.basex.api.client.Session.execute(Session.java:36)
......