Questions tagged [inputstreamreader]
216 questions
                    
                    59
                    
            votes
                
                7 answers
            
        What is the difference between Java's BufferedReader and InputStreamReader classes?
What is the difference between Java's BufferedReader and InputStreamReader classes?
         
    
    
        Ajay Yadav
        
- 1,625
- 4
- 19
- 29
                    43
                    
            votes
                
                8 answers
            
        Read all lines with BufferedReader
I want to type a multiple line text into the console using a BufferedReader and when I hit "Enter" to find the sum of the length of the whole text. The problem is that it seems I'm getting into an infinite loop and when I press "Enter" the program…
         
    
    
        deadpixels
        
- 769
- 1
- 12
- 21
                    17
                    
            votes
                
                3 answers
            
        How do an InputStream, InputStreamReader and BufferedReader work together in Java?
I am studying Android development (I'm a beginner in programming in general) and learning about HTTP networking and saw this code in the lesson:
private String readFromStream(InputStream inputStream) throws IOException {
  StringBuilder output = new…
         
    
    
        schv09
        
- 995
- 1
- 9
- 15
                    11
                    
            votes
                
                6 answers
            
        InputStreamReader buffering issue
I am reading data from a file that has, unfortunately, two types of character encoding.
There is a header and a body.  The header is always in ASCII and defines the character set that the body is encoded in.
The header is not fixed length and must…
         
    
    
        Mike Q
        
- 22,839
- 20
- 87
- 129
                    11
                    
            votes
                
                2 answers
            
        Closing BufferedReader and InputStreamReader
This piece of code is creating memory leak issues cause of BufferedReader and InputStreamReader which I think might be happening cause of some exceptions. How should I change it?    
try{
    URL url = new URL(sMyUrl);
    BufferedReader in = new…
         
    
    
        Pit Digger
        
- 9,618
- 23
- 78
- 122
                    8
                    
            votes
                
                2 answers
            
        Read both text and binary data from InputStream
I am trying to read data from a binary stream, portions of which should be parsed as UTF-8.
Using the InputStream directly for the binary data and an InputStreamReader on top of it for the UTF-8 text does not work as the reader will read ahead and…
         
    
    
        tajmahal
        
- 1,665
- 3
- 16
- 29
                    7
                    
            votes
                
                3 answers
            
        problem using base64 encoder and InputStreamReader
I have some CLOB columns in a database that I need to put Base64 encoded binary files in.
These files can be large, so I need to stream them, I can't read the whole thing in at once.
I'm using org.apache.commons.codec.binary.Base64InputStream to do…
         
    
    
        karoberts
        
- 9,828
- 4
- 39
- 39
                    7
                    
            votes
                
                6 answers
            
        DataInputStream vs InputStreamReader, trying to conceptually understand the two
As I tentatively understand it at the moment:
DataInputStream is an InputStream subclass, hence it reads and writes bytes. If you are reading bytes and you know they are all going to be ints or some other primitive data type, then you can read those…
         
    
    
        ross studtman
        
- 936
- 1
- 8
- 22
                    7
                    
            votes
                
                2 answers
            
        BufferedReader in a multi-core environment
I have 8 files. Each one of them is about 1.7 GB. I'm reading those files into a byte array and that operation is fast enough.
Each file is then read as follow:
BufferedReader br=new BufferedReader(new InputStreamReader(new…
         
    
    
        DotNet
        
- 697
- 2
- 7
- 23
                    7
                    
            votes
                
                2 answers
            
        How make InputStreamReader fail on invalid data for encoding?
I have some bytes which should be UTF-8 encoded, but which may contain a text is ISO8859-1 encoding, if the user somehow didn't manage to use his text editor the right way.
I read the file with an InputStreamReader:
InputStreamReader reader = new…
         
    
    
        Daniel
        
- 27,718
- 20
- 89
- 133
                    6
                    
            votes
                
                2 answers
            
        Readline is too slow - Anything Faster?
I am reading in from a stream using a BufferedReader and InputStreamReader to create one long string that gets created from the readers.  It gets up to over 100,000 lines and then throws a 500 error (call failed on the server).  I am not sure what…
         
    
    
        butler_alfred
        
- 83
- 2
- 11
                    5
                    
            votes
                
                6 answers
            
        Java inputStreamReader Charset
I want to ping a target IP address and receive a response. To achieve this, I'm using windows command line in Java with runtime.exec method and process class. I'm getting the response using inputStreamReader.
My default charset is windows-1254, it's…
         
    
    
        Maozturk
        
- 339
- 1
- 5
- 20
                    4
                    
            votes
                
                1 answer
            
        Why does InputStreamReader read() block instead of returning -1?
I'm using java's InputStreamReader read() function. When I reach the end of the input stream i'm supposed to get in to my int variable the value of -1, but instead it goes to block.
Why don't I get a -1 at the end of the input stream? (i've debugged…
         
    
    
        Guy
        
- 41
- 2
                    4
                    
            votes
                
                2 answers
            
        Java Scanner for peeking something (int, double, line, etc) without advancing position
We know that nextInt(), nextDouble(), nextLine(), etc methods of Java Scanner class parses something (int, double, line, etc) and advances the position of the scanner. But I need a way only for parsing something but not for advancing the position.…
         
    
    
        arnobpl
        
- 1,126
- 4
- 16
- 32
                    4
                    
            votes
                
                5 answers
            
        Java BufferedReader.readLine() not waiting for EOL?
Sorry if I'm missing something obvious here...but please take a look at this code snippet:
String readString;
String writeString = "O hai world.";
BufferedReader br = new BufferedReader(
    new InputStreamReader( 
        new…
         
    
    
        jasterm007
        
- 163
- 3
- 9