Dear all JLine users,
I am recently developing a console application where I use JLine, to provide command and file name completion.
It works pretty well with FileNameCompleter but however I cannot get the full file name right.
My code is like below:
List<Completer> loadCompleter =
Arrays.asList(
new StringsCompleter(commands),
new FileNameCompleter(),
new NullCompleter()
);
console.addCompleter(new ArgumentCompleter(loadCompleter));
while ((line = console.readLine()) != null) {
line = line.trim();
// here I print out the line in char.
char[] result = line.toCharArray();
for (int i = 0; i < result.length; i ++) {
System.out.println(result[i] + " : " + (int)result[i]);
}
}
In the last part of my code I am printing out the line I got from the console, if for example, I have received
myCommand test\new\test.txt
the output is myCommand testnewtest.txt
The backward slash is gone for some reason and I never got the right file path. This is not an issue when I am testing in Unix like system since forward slash seems ok.
Can anyone help me on the right way of getting the full filename? Many thanks.
Si.