Skip to content

LoadFileText method not working as intended #70

@redfox4ever

Description

@redfox4ever

When I call LoadFileText it returns a ByteBuffer with the capacity of 1 regardless of the content of the file loaded.

package com.redfox.platformer;

import java.nio.ByteBuffer;

import static com.raylib.Colors.RAYWHITE;
import com.raylib.Raylib;
import static com.raylib.Raylib.BeginDrawing;
import static com.raylib.Raylib.ClearBackground;
import static com.raylib.Raylib.CloseWindow;
import static com.raylib.Raylib.EndDrawing;
import static com.raylib.Raylib.InitWindow;
import static com.raylib.Raylib.WindowShouldClose;

public class Game {
    public static void main(String[] args) {
        int screenWidth = 800;
        int screenHeight = 600;
        InitWindow(screenWidth, screenHeight, "raygui");
        while (!WindowShouldClose()) {
            BeginDrawing();
            ClearBackground(RAYWHITE);
            EndDrawing();
        }
        CloseWindow();
        ByteBuffer text = Raylib.LoadFileText("resources\\Text.txt");
        System.out.println(text.capacity());  // 1
        while(text.hasRemaining())
        {
            System.out.printf("%c", (char)text.get());
        }   
        System.out.println(); 
    }
    
}

resources/Text.txt:

esfsdfsdfsdfs
sdfsdfds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions