Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAEL-1760 Console I/O in Java #4379

Merged
merged 22 commits into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
db2e971
ivan.ljubicic.app.developer@gmail.com
IvanLjubicic Feb 25, 2018
e9489d2
Added unit tests, configuration class and minor adjustments
IvanLjubicic Feb 26, 2018
e1737c1
Merge branch 'master' of https://github.com/IvanLjubicic/tutorials.git
IvanLjubicic Mar 18, 2018
aaa4f66
primefaces intro module added
IvanLjubicic Mar 18, 2018
f597ff5
deleted primefaces old module
IvanLjubicic Mar 18, 2018
f0160a7
deleted different bean injection types sample project
IvanLjubicic Mar 18, 2018
dd67c74
deleted addition different bean injection types file
IvanLjubicic Mar 18, 2018
c666b29
Renaming archetype in web.xml
IvanLjubicic Mar 18, 2018
810a54c
Added primefaces in jsf module
IvanLjubicic Mar 23, 2018
0feeabe
Primefaces improvements
IvanLjubicic Apr 3, 2018
6c7cdf7
Added commandButton and dialog
IvanLjubicic Apr 19, 2018
4c60d50
Added PFM
IvanLjubicic Apr 21, 2018
459aada
Code formatting
IvanLjubicic Apr 30, 2018
cb224e1
Update pom.xml
daoire May 1, 2018
d948458
Formatting changes
daoire May 1, 2018
6c5274f
Merge branch 'master' into master
daoire May 1, 2018
39e2b39
ConsoleDemo initial version
IvanLjubicic May 31, 2018
c3d7f0c
Merge branch 'master' into master
pivovarit Jun 6, 2018
2a91319
Added new classes, renamed ConsoleDemo class
IvanLjubicic Jun 11, 2018
bb9acb3
Merge branch 'master' of https://github.com/IvanLjubicic/tutorials.git
IvanLjubicic Jun 11, 2018
bf31ba7
Removed System.in class, renamed Scanner class and reorganized
IvanLjubicic Jun 20, 2018
e9a6ed7
Added more method examples
IvanLjubicic Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added new classes, renamed ConsoleDemo class
  • Loading branch information
IvanLjubicic committed Jun 11, 2018
commit 2a913195cb8e46efbb47c20fea0e06e68d3996b5
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.baeldung.console;

import java.io.Console;

public class ConsoleConsoleClass {

public static void main(String[] args)
{
Console console = System.console();

if(console == null)
{
System.out.print("No console available");
return;
}

String progLanguauge = console.readLine("Enter your favourite programming language: ");
console.printf(progLanguauge + " is very interesting!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Scanner;

public class ConsoleDemo {
public class ConsoleScanner {

public static void main(String[] args)
{
Expand Down
30 changes: 30 additions & 0 deletions core-java/src/main/java/com/baeldung/console/ConsoleSystemIn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.baeldung.console;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ConsoleSystemIn {

public static void main(String[] args)
{
System.out.println("Please enter number of years of experience as a developer: ");

BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));

int i = 0;

try {
i = Integer.parseInt(buffReader.readLine());
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println("You are a " + (i > 5? "great" : "good") + " developer!");
}

}