Results 1 to 2 of 2
Thread: What is end of input character?
- 01-28-2013, 01:56 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 1
- Rep Power
- 0
What is end of input character?
Hi there!
What is end of input character? I wanted to read in input from standard input and find a max but i don't know it does not work. Here is my code:
Java Code:import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; public class maxNum { public static void main(String[] args) throws IOException{ BufferedReader buff=new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> arr= new ArrayList<Integer>(); // String s; //Integer i=0; while(buff.read()!=-1){ arr.add(buff.read()); } Integer max=0; for(int j=0; j<arr.size(); j++){ max=Math.max(max, arr.get(j)); } System.out.println(max); } }
- 01-28-2013, 03:41 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 26
Re: What is end of input character?
Java Code:while(buff.read()!=-1) { arr.add(buff.read()); }
You need to assign that first read to a variable and then add that variable to your array.Please do not ask for code as refusal often offends.
** This space for rent **
Similar Threads
-
Inserting consecutive character runs with different character properties using Apache
By pingale in forum Apache POIReplies: 1Last Post: 11-06-2012, 03:29 PM -
Inserting consecutive character runs with different character properties using Apache
By pingale in forum Apache POI ExamplesReplies: 0Last Post: 11-06-2012, 03:09 PM -
Inserting consecutive character runs with different character properties using Apache
By pingale in forum Apache POI CodesReplies: 0Last Post: 11-06-2012, 03:09 PM -
How to create UPPERCASE formatted text field with mixed character input
By r00tb33r in forum AWT / SwingReplies: 2Last Post: 08-21-2010, 11:53 AM -
count character in text file as input file
By aNNuur in forum New To JavaReplies: 7Last Post: 03-25-2010, 05:01 PM
Bookmarks