Error: cant find symbol Path

Milestone 1: I followed the hints and came up with this.

final Path path = resolveFileFromResources(args[0]);
final byte[] bytes = Files.readAllBytes(path);
String fileContent = new String(bytes);

When I try to run it I get this,

error: cannot find symbol
final Path path = resolveFileFromResources(args[0]);
^
symbol: class Path
location: class PortfolioManagerApplication
1 error

Looked up on this and found that Paths has already been imported so not able to figure out the problem. @Rahul-Crio.do @chandra-kiran_crio @sashi_Crio.Do

After adding

import java.nio.file.Path;

this I get this error:

error: incompatible types: File cannot be converted to Path
final Path path = resolveFileFromResources(args[0]);
^
1 error

The thing is return type of resolveFileFromResources() is not Path, try looking the reslveFileFromResources() function and see what is the return type of this function.

It returns a File type. So, should I convert it to String then?

Nah,the type is File so use it instead of Path.

final File file = resolveFileFromResources(args[0]);

Doing this will only return me the filename. But I need the path right?

File name is the whole FilePath ,you can try printing it out and check yourself. Also you need to use objectMapper to get content of file.

I get this error

error: incompatible types: File cannot be converted to Path
final byte[] bytes = Files.readAllBytes(file);

If I change to this

final File file = resolveFileFromResources(args[0]);
final byte[] bytes = Files.readAllBytes(file); @ankyy

Use objectMapper and try to understand how it works, use google.

Use Path.get(file) instead of file inside Files.readAllBytes()
Refer this link and use method 5 or 6

And for mapping JSON to java objects use object mapper

Hey you do not have to make any changes with the any of the other functions, just make the required changes in the mainReadFile() function

Hey since, you have posted a new ticket on the portal, for a new problem , I assume you have already got the solution for this, I am closing this ticket :slight_smile: