byte to string android

android, byte, string

Solution

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);

Problem

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(); } ```

Original source