Questions tagged [stringreader]

84 questions
35
votes
4 answers

StringBuilder Vs StringWriter/StringReader

I recently read that in StringWriter and StringReader are used for writing and reading from StringBuilder. Well when I use StringBuilder Object, it looks to be a self sufficient class. We have every way of reading and writing the StringBuilder,…
SaravananArumugam
  • 3,540
  • 6
  • 29
  • 45
27
votes
2 answers

How to replace StringBufferInputStream with StringReader?

Using JNLP, I have this line : File_Save_Service.saveFileDialog(null,null,new StringBufferInputStream("testing"),null); How to replace StringBufferInputStream with StringReader in this line ? The API for StringBufferInputStream says better use…
Frank
  • 28,342
  • 54
  • 158
  • 227
20
votes
5 answers

Should I close a StringReader?

I use a StringReader to turn a string into something I can upload to an SFTP server (it takes a stream). Is there any point in closing that StringReader afterwards? As far as I can see in the source it just sets the string to null... I could just do…
Svish
  • 138,188
  • 158
  • 423
  • 589
20
votes
10 answers

How do I convert a StringReader to a String?

I'm trying to convert my StringReader back to a regular String, as shown: String string = reader.toString(); But when I try to read this string out, like this: System.out.println("string: "+string); All I get is a pointer value, like…
Zibbobz
  • 677
  • 1
  • 11
  • 36
10
votes
3 answers

Why Java StringReader throws IOException?

Today I was working with Java class StringReader and I found it very annoying that it throws IOException on read method. I know that it extends Reader class in which method read throw IOException but I think that it is not needed for StringReader.…
Paweł Adamski
  • 2,765
  • 2
  • 21
  • 40
8
votes
2 answers

Ignoring specified encoding when deserializing XML

I am trying to read some XML received from an external interface over a socket. The problem is that the encoding is specified wrong in the XML-header (it says iso-8859-1, but it is utf-16BE). It is documented that the encoding is utf-16BE, but…
Holstebroe
  • 4,667
  • 1
  • 26
  • 44
6
votes
4 answers

C# StringReader Class

I have this problem, I'm using StringReader to find specific words from a textbox, so far is working great, however I need to find a way how to check specific words in every line against a string array. The following code works: string txt =…
5
votes
1 answer

How to string multiple TextReaders together?

I have 3 TextReaders -- a combination of StreamReaders and StringReaders. Conceptually, the concatenation of them is a single text document. I want to call a method (not under my control) that takes a single TextReader. Is there any built-in or…
Ken
  • 396
  • 2
  • 4
5
votes
3 answers

Tagsoup fails to parse html document from a StringReader ( java )

I have this function: private Node getDOM(String str) throws SearchEngineException { DOMResult result = new DOMResult(); try { XMLReader reader = new Parser(); …
zajcev
  • 293
  • 2
  • 7
4
votes
4 answers

How to reset position in StringReader to begining of String?

I have the following code: StringReader contentReader = new StringReader(this.dataContent.ToString()); After I parse my DataContent, I need to reset the poistion of the contentReader to begining of the string. How do I do it? I dont see a set…
savi
  • 477
  • 2
  • 10
  • 26
3
votes
2 answers

StringReader gives error from String.Split output

I got an exception when using StringReader. The string that I parse when creating object was produced trough String.split, it gives me NullPointerException. Any suggestion how to fix this? Here's the code: public static void main(String[] args)…
jajamaharaja
  • 156
  • 12
3
votes
1 answer

Can not unmarshall the SOAP response

I could send a request and receive the response but I can not parse the response. It returns the following error: Local Name:Body error is here java.lang.NullPointerException at…
J888
  • 1,804
  • 8
  • 39
  • 73
3
votes
1 answer

Append StringReader For Multiple Entries

I'm creating a program in Java that reads a string of XSL-FO code, populates the empty fields with app data, and adds it to a StringReader, to eventually be set as an InputSource for a web dispatcher. I already have the code to find and populate…
Zibbobz
  • 677
  • 1
  • 11
  • 36
2
votes
1 answer

Is it necessary to close the StringReader in this case?

Document doc = DocumentBuilderFactory.newInstance(). newDocumentBuilder(). parse(new InputSource(new StringReader(xml)));
2
votes
4 answers

C# Read text file line by line and edit specific line

I want to read a text file line by line and edit a specific line. So, I have put the text file into a string variable like: string textFile = File.ReadAllText(filename); My text file is like: Line A Line B Line C Line abc Line 1 Line 2 Line 3 I…
Giovanni19
  • 85
  • 1
  • 2
  • 7
1
2 3 4 5 6