So I'm using files to save some scores of my program but the problem is that I don't can't just print them. I tryed several things but I don't find the right one the is my code:
try{
        String FILENAME = "FrogScoreFile";
        FileInputStream fos = openFileInput(FILENAME);
        byte[] b = new byte[1];
        fos.read(b);
        fos.close();
        String score= String b;
        game5HighScore.setText(b);
        }catch (java.io.FileNotFoundException e) {
        } catch (IOException e) {
                e.printStackTrace();
    }
                You can convert Byte array to string by creating new string object.
byte[] b = new byte[1];
fos.read(b);
fos.close();
String message = new String(b);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With