Question: How would I go about reading the first 5 lines from a text file in java using a buffered Reader or Scanner? Here is my code

```
        final int assumedLineLength = 16;

    File file = new File("src/hw7p1/Acronyms.txt");
     HashMap<String, String> hashMap = new HashMap<String, String>((int)(file.length() / assumedLineLength) * 2);
    BufferedReader reader = null;
    int linecount = 0 ;
    String eachLine = null;
    try {
    reader = new BufferedReader(new FileReader(file));

    for ( eachLine = reader.readLine(); 
            eachLine != null; 
            eachLine = reader.readLine()) {
        hashMap.put(eachLine, " ");
        linecount++; int i = 0;

    }

    TreeMap<String, String> sorted = new TreeMap<>(hashMap);

     Set<Entry<String, String>> sortings = sorted.entrySet();

    for(Entry<String, String> sort : sortings){ 
        System.out.println(sort.getKey() + " " + sort.getValue());

    }

     }catch (IOException e) {
         e.printStackTrace();
     }

```

}
It prints out the text file, but what I am trying to do is just to get it to print out the first 5 lines. Any help would be appreciated.

Answer: 
You can either use `className` or `cssText` to do so.
If you used className, you need to define the class in CSS.

```js
// By setting css class name
var buttonShort = document.createElement("button");
buttonShort.innerHTML = "Generate Short Password";
// set class name 
buttonShort.className = "button";
var body = document.getElementsByTagName("body")[0];
body.appendChild(buttonShort);

// Or using JS
var buttonShort = document.createElement("button");
buttonShort.innerHTML = "Generate Short Password 2";
// set CSS name  using js
buttonShort.style.cssText = "border: 1px solid black; background-color:blue;height: 20px;color:white";
var body = document.getElementsByTagName("body")[0];
body.appendChild(buttonShort);
```

```css
.button {
 border: 1px solid black ;
 background-color: orange;
 height: 20px;
}
```
put this into head tag:

```
<style>
p.ex3 {
      font-size: 15px;
    }
</style>

```

and put this into body:

```
<div><p id="demo" class="ex0">Led Off</p></div>
<button type="button" onclick='document.getElementById("demo").innerHTML = "Led 
On"'><p class="ex3">Led On</p></button>

```