#Debugging issues
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
I uploaded your attachments as Gist.
and here is the console :
BufferedReader br = new BufferedReader(new InputStreamReader(is));
ah well the problem is the way you try to load the file
it is in the resources folder right?
yess, his path is /res/maps/maptestdata.txt
get the input stream from resources using getClass().getResourceAsStream(...)
like this ?
InputStream is = getClass().getResourceAsStream("file:/res/maps/maptestdata.txt");
yeah
well
remove the file:
you dont need that
also you should take a look at try with resource
yeah, I had an issue earlier with another file and that was the way I fixed it (and i don't know why)
where is it ?
is it basically what you have, but with a try(...)
read the article
it explans in detail
yeah reading it, thanks !
especially related to your inputstream and bufferreader as they are AutoCloseable
so like this if I understood well ?
public TileManager(GamePanel gPanel) {
this.gPanel = gPanel;
this.tileSize = GamePanel.getTileSize(); // Obtient la taille des tuiles depuis GamePanel
try (InputStream is = getClass().getResourceAsStream("/res/maps/maptestdata.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = br.readLine()) != null) {
fileNames.add(line);
collisionStatus.add(br.readLine());
}
} catch (IOException e) {
e.printStackTrace();
}
tiles = new Tile[fileNames.size()];
loadTileImages();
mapTileNum = new int[gPanel.WORLD_WIDTH][gPanel.WORLD_HEIGHT];
loadTileImages();
loadMap("file:res/maps/maptest.txt"); // Assurez-vous que loadMap est appelé ici pour remplir mapTileNum
}
so it did'nt worked for me
: If you are in need of help with Java programming, the "Java Q&A" category on our Discord server is the perfect place for you. Whether you are struggling with a specific coding problem, looking for guidance on best practices, or seeking recommendations for resources, our community of experienced Java developers is here to assist you.
To get help in the Java Q&A category, simply post your question or issue in the chat and wait for a response from fellow members. Be sure to provide as much detail as possible to help others understand the problem and offer accurate solutions. Additionally, remember to follow the server rules and guidelines to maintain a respectful and productive environment for all participants.
Our Java Q&A category is a valuable resource for anyone looking to improve their programming skills or overcome challenges in their projects. By engaging with our community of experts and enthusiasts, you can gain valuable insights, learn new techniques, and ultimately enhance your proficiency in Java development.
Don't hesitate to reach out for assistance in the Java Q&A category – we are here to support you on your journey to becoming a proficient Java programmer.