read complete file without using loop in java
Java 7 one line solution
List<String> lines = Files.readAllLines(Paths.get("file"), StandardCharsets.UTF_8);
or
String text = new String(Files.readAllBytes(Paths.get("file")), StandardCharsets.UTF_8);
If the file is small, you can read the whole data once:
File file = new File("a.txt");
FileInputStream fis = new FileInputStream(file);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
String str = new String(data, "UTF-8");