H
H
hHup2018-04-24 23:26:08
Java
hHup, 2018-04-24 23:26:08

C++ file path?

The story is this, in java there is a file on a relative path (res/filetxt/txt1.txt), from java I load the C ++ code that is closed in the DLL. And when this code is executed, I have to read this very file, how can I specify the relative path? and regarding what it will be, the whole joke is that as a result I throw off the jar file to another PC, and the C ++ code does not see this very txt , it turns out now that the full path of this very file depends on the location of the jar itself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2018-04-25
@leahch

It's actually good to hide such things in resources, and load them relatively via getResource()
Here it is written in detail - https://skipy-ru.livejournal.com/5343.html
Well, the current directory can be obtained like this

Path currentRelativePath = Paths.get("");
String s = currentRelativePath.toAbsolutePath().toString();
System.out.println("Current relative path is: " + s);

Or try like this
AND javatutorialhq.com/java/example-source-code/io/fil...

A
anikavoi, 2018-04-25
@anikavoi

What's stopping you from passing the path to the DLL function?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question