#Setting path for file inside java project

1 messages · Page 1 of 1 (latest)

elder frost
#

right now i have file inside my java project and filePath is set to/Users/myName/Desktop/directory/projectName-rest/src/main/resources/zip_code_market_tracker.csv. But when I deploy this it my path will break.

broken hillBOT
#

<@&987246399047479336> please have a look, thanks.

broken hillBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

elder frost
lament forge
old canyon
#

Anyways, OP you can use the getResource method to grab the file in your resources folder

elder frost
lament forge
#

wait, is this really an example from their official docs ?
that's messed up 🤔
@old canyon

old canyon
#

Yeah but it's a dumb example lol

#

Out of all the paths they could have put

lament forge
old canyon
#

Well nobody said spark was a good framework 😂

#

Even though we use it at government 😔

#

(not for prod tho)

elder frost
#

uh oh, should I look into something else ? im open to suggestions . @old canyon

#

opening a tsv/csv file with 7 million records

lament forge
umbral schooner
#

Path path = Paths.get()

lament forge
umbral schooner
#

Then read with CsvReader

elder frost
umbral schooner
#

That san example I know already

lament forge
#

but you shouldn't do that at the first place

#

you should use Class.getResource or better, Class.getResourceAsStream

umbral schooner
#

Aha

#

Alright. Going to try that out

#

Thanks

spring owl