// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class StringAppend {
    public static String dupl1(String v, int n) {
        String s = "";
        for(int i = 0; i < n; i++) {
            s = s + v;
        }
        return s;
    }
    public static String dupl2(String v, int n) {
        StringBuilder sb = new StringBuilder("");
        for(int i = 0; i < n; i++) {
            sb.append(v);
        }
        return sb.toString();
    }
    public static String load1(String filename) throws IOException {
        String s = "";
        try(BufferedReader br = new BufferedReader(new FileReader(filename))) {
            String line;
            while((line = br.readLine()) != null) {
                s = s + line + "\r\n";
            }
        }
        return s;
    }
    public static String load2(String filename) throws IOException {
        StringBuilder sb = new StringBuilder("");
        try(BufferedReader br = new BufferedReader(new FileReader(filename))) {
            String line;
            while((line = br.readLine()) != null) {
                sb.append(line);
                sb.append("\r\n");
            }
        }
        return sb.toString();
    }
    public static void main(String[] args) throws IOException {
        System.out.println(dupl1("ABC", 5));
        System.out.println(dupl2("ABC", 5));
        System.out.println(load1("/work/Test.java"));
        System.out.println(load2("/work/Test.java"));
    }
}
