f



cast java.io.PushbackReader to java.io.Reader?

Hi all,

I have a function in Matlab that makes a database call and returns a
java.io.Reader instance.  Matlab seems to automatically convert this
to a PushbackReader.  Is there a way to force it to remain as just a
Reader, or cast it to a Reader after the fact?

Here's what it looks like:

 try
  xmlReader =
myDBClient.read(java.lang.String(myXMLDocumentIdentifierString)) ...
  catch
    display([lasterr]);
  end

result:
xmlReader        1x1      java.io.PushbackReader

where DBClient.read() signature is:

public Reader read(String xmlDocumentIdentifier) {}

The XML document identifier is just an internal accession string that
uniquely identifies individual documents.

Thanks in advance,
Chris
0
vmcdirect (4)
3/7/2008 9:05:39 PM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
876 Views

Similar Articles

[PageSpeed] 18

 For those that are intersted in handling XML Reader objects in
Matlab, here is what I did:

Instead of creating the xmlReader variable (which gets converted to a
PushbackReader), I just send the Reader directly into my class that
produces a DOM document (which was my desired result in the first
place):

myDOMDocument = myXMLUtilities.getXMLReaderAsDOMDocument( ...
 
myDBClient.read(java.lang.String(myXMLDocumentIdentifierString));

result:

myDOMDocument        1x1
org.apache.xerces.dom.DeferredDocumentImpl

I can now go on my merry way and modify my XML document via the DOM
API, etc.

Hope this helps someone in the future,
Chris
0
vmcdirect (4)
3/19/2008 2:46:39 PM
Reply:

Similar Artilces:

How do I fix: "Incompatible type for constructor. Can't convert java.io.InputStream to java.io.Reader."
Hi, First, let me state "I am not a Java programmer.", but I need to write a Java stored procedure for use in an Oracle database instance. The code fragment I am having issues with is: Process p = Runtime.getRuntime().exec(cmd); BufferedReader r = new BufferedReader(p.getInputStream()); I have tried to understand the class hierarchy on java.sun.com, but I am lost. Can someone lend a hand, or point me to a source which will explain this to me? Thanks so much for your time. rr Ron Reidy wrote: > Hi, > > First, let me state "I am not a Java programmer.&qu...

java.io.FileReader and java.io.FileWriter encoding
Hi, I recently changed the hosting for my website (from Linux to Linux) and now I'm experiencing some trouble with java.io.FileReader and java.io.FileWriter: their getEncoding() method returns ASCII (returned ISO8859_1 on the previuos host). I've set -Dfile.encoding=ISO-8859-1 but nothing has changed, except that javax.mail.internet.MimeUtility.getDefaultJavaCharset() effectively returns ISO-8859-1. Does anyone know how the default encoding is selected? I report some system properties: file.encoding.pkg: sun.io user.country: US java.runtime.version: 1.4.2_04-b05 os.version: 2...

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:
I have an application that came to a grinding halt yesterday for no apparent reason. After looking into it I discovered that the file system had reached its capacity. My java guru is on holidays and wont be back for a week so I have been left to try and resolve this in his absence. In the tomcat logs directory the file "localhost_log-YYY-MM-DD.txt" is growing to 45MB in size every day. When looking into the file it contains the same error message over and over again: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: I have checked the Catalina.lo...

java.io.File.getAbsolutePath() vs. java.io.File.getCanonicalPath()
What is the meaning of the term Canonical Path? The API makes it fairly clear does it not? ...https://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#getCanonicalPath()On Mar 5, 3:03 pm, "Sathyaish" <sathya...@gmail.com> wrote:> What is the meaning of the term Canonical Path? Thank you.Sorry, I hadn't scrolled down to the complete definition. Also tried out an example. Sorry for being lazy the first time. I wastrying to save some time. No harm in that.On Mar 5, 3:38 pm, "Sathyaish" <sathya...@gmail.com> wrote:> Also tried out an example. Sorry for b...

java.io.BufferedWriter and java.io.PrintStream
Hi, I was just examining the SDK API and noticed this method in PrintStream: private void write(char buf[]) { try { synchronized (this) { ensureOpen(); textOut.write(buf); textOut.flushBuffer(); charOut.flushBuffer(); if (autoFlush) { for (int i = 0; i < buf.length; i++) if (buf[i] == '\n') out.flush(); } } } catch (InterruptedIOException x) { Thread.currentThread().interrupt(); } catch (IOException x) { trouble = true; } } I also noticed that there is no write method in BufferedWriter that takes a char array as its only argumen...

matlab in JAVA or java in MATLAB?
Hi guys I am now experencing a great difficulty in the interation between java and matlab. I have an objective function written in JAVA with has method return an numerical number, i call it 'profit'. The nature of this obtive function (ObjFun.java) is that it takes an parameter input, say C, with different C value, the returned profit value is different. Eventually I want to find the optimized C value which produce the maximun profit (C will be under constrains). Initially I want to use linprog or fminsearch in matlab. So I tried the command in matlab that excutes my ObjFun.ja...

java.io.File to java.lang.String
What's the best way to get the contents of a file represented by ajava.io.File object into a String? Benjamin wrote:> What's the best way to get the contents of a file represented by a> java.io.File object into a String?> You don't specify what you consider best so how about simple as best? Now for my curiosity, why would you want to do this?import java.io.*;public class test { public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); File f = new File(args[0]); FileInputStream fis = new ...

Charset names in java.io and java.nio
Hi guys, Why is character set Cp1047 known in java.io but not in java.nio.charset.Charset? Enclosed nio and io examples illustrate what I mean. Cheers, Vince NIO EXAMPLE public class NioTest { public static void main( String[] args) throws Exception { java.nio.charset.Charset.forName("Cp1047"); } } COMMENTS An exception is thrown: Exception in thread "main" java.nio.charset.UnsupportedCharsetException: Cp1047 at java.nio.charset.Charset.forName(Charset.java:486) at NioTest.main(NioTest.java:3) IO EXAMPLE import java.io.InputStreamReade...

java stored procedure java.io.IOException
Hello, i have a java stored procedure which read, write files. Since a few days i have problem if the file is greater 32K i get a java.io.IOException (write 32k is okay write next block with 16k -> Exception). I use sun solaris with oracle 8.1.7. There is enough space on the filesystem. I hope some one has an idea, Thanks. best regards Thomas ...

matlab in JAVA or java in MATLAB? #2
Hi guys I am now experencing a great difficulty in the interation between java and matlab. I have an objective function written in JAVA with has method return an numerical number, i call it 'profit'. The nature of this obtive function (ObjFun.java) is that it takes an parameter input, say C, with different C value, the returned profit value is different. Eventually I want to find the optimized C value which produce the maximun profit (C will be under constrains). Initially I want to use linprog or fminsearch in matlab. So I tried the command in matlab that excutes my ObjFun.ja...

Is any IO format reader in Java?
in java.io.*;In PrintWriter and PrintStream classesthey both have two format(...) methods.So I can write similar like C/C++printf, fprintf and sprintf in format like %5.1f.But I can't find an IO class has format readersimilar to C/C++scanf, fscanf and sscanfI have some input data look like" 0.1-10.2" (two spaces at the front).They are two float numbers 0.1 and -10.2 (NOT 0.1 minus 10.2)!The best way to read this is read them in format "%5.1f%5.1f"If the data look like " 0.1 -10.2", then I can use StringTokenizerNow I have to read 5 characters a time! On Aug ...

java error message java.io not found in import
Hi i'm trying to run a code like but i'm getting all the time the same error Class java.io not found in import import Java.io i guess the problem is that i dont have the header in the include folder,doenst anyone have solution for me? thread wrote: > Hi i'm trying to run a code like but i'm getting all the time the same > error > Class java.io not found in import > import Java.io 1. Capitalization matters. The package name is `java.io', not `Java.io' 2. The first-person subjective pronoun is `I', not `i'. 3. There is no class `java.io'; there ...

Java Java
Have my first Open Source Linux Java Project. Working on a second right now. Coming out with a distro called OPEN*WINDOWS. It will be at www.black-and-company.com tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a distro called OPEN*WINDOWS. > > It will be at www.black-and-company.com > Wasn't that the whole point of Lindows? Oh, right, we didn't care for that either. tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a ...

Java in Java
Is it possible to download a Java app (applet etc?) and run it inside a desktop Java app? -- Dirk http://www.transcendence.me.uk/ - Transcendence UK http://www.theconsensus.org/ - A UK political party http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff Dirk Bruere at NeoPax wrote: > Is it possible to download a Java app (applet etc?) and run it inside a > desktop Java app? > Quite likely, but you won't necessarily get the same security model, unless you were careful about it. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/&g...

Web resources about - cast java.io.PushbackReader to java.io.Reader? - comp.soft-sys.matlab

Resources last updated: 1/28/2016 5:50:48 PM