StringBuffer sbuffer = new StringBuffer(); Scanner input = new Scanner(System.in); System.out.println("Enter a string"); sbuffer.append(input.nextLine());