LinuxHelper { public static String[] getFileLineSplit(RandomAccessFile raf) { try { raf.seek(0); String line = raf.readLine(); if (line == null) return new String[0]; return SPACES_PATTERN.split(line); } catch (IOException ignored) { return new String[0]; } } protected  LinuxHelper(); static long getPageSize(); static String[] getFileLineSplit(RandomAccessFile raf); static RandomAccessFile openFile(File file); static final Pattern COUNT_PATTERN; }
@Test public void getFileLineSplit() throws IOException { String[] split; try (RandomAccessFile raf = new RandomAccessFile(LinuxHelperTest.class.getResource("/smaps.txt").getFile(), "r")) { split = LinuxHelper.getFileLineSplit(raf); } Assert.assertEquals(8, split.length); Assert.assertEquals("cpu", split[0]); Assert.assertEquals("12429873894", split[1]); Assert.assertEquals("112423", split[2]); Assert.assertEquals("2578676578", split[3]); Assert.assertEquals("95690623088", split[4]); Assert.assertEquals("77250562", split[5]); Assert.assertEquals("0", split[6]); Assert.assertEquals("357862258", split[7]); }