Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. import java.io.*;
  4.  
  5. public class FixText {
  6.  
  7. public String readString() {
  8. try( BufferedReader br=new BufferedReader(new InputStreamReader(System.in)) ){
  9. String line=br.readLine();
  10. return line;
  11.  
  12. }catch(IOException e) { e.printStackTrace();}
  13. return null;
  14.  
  15.  
  16. };
  17.  
  18. // From java 1.6
  19.  
  20. public String getString2() {
  21.  
  22. try(Scanner s= new Scanner(System.in)){
  23. return s.nextLine();
  24.  
  25. }
  26. }
  27. /*
  28. public void readString2() {
  29.  
  30. try( LineNumberReader lnr= new LineNumberReader(new FileReader(fileName))){
  31. String line=null;
  32. while((line=lnr.readLine())!=null)
  33. if( line.indexOf(sir)>-1)
  34. System.out.println(lnr.getLineNumber()+": "+line);
  35. }catch(IOException e) {e.printStackTrace();}
  36.  
  37.  
  38. }
  39.  
  40. */
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement