cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ray Martin" <raymar...@aci-hq.com>
Subject RE: How do I read files inside an Action?
Date Thu, 19 Dec 2002 19:13:30 GMT
not sure what it is that you want!!!  did you ever hear of Xerces? - ya
know, XML parsers? - SAX event generators? - or, are you looking for
something else?

> -----Original Message-----
> From: Chintalapaty, Sreedhar [mailto:schintalapaty@ptc.com]
> Sent: Thursday, December 19, 2002 12:07 PM
> To: cocoon-users@xml.apache.org; cocoon-users@xml.apache.org
> Subject: RE: How do I read files inside an Action?
>
>
> Sorry for the confusion, I should have phrased my question
> better. What I wanted to know was how to read in an XML file _as
> an XML Document_ object. I intend to use that object to determine
> the flow of control.
>
> Sreedhar
>
>
> -----Original Message-----
> From:	Ray Martin [mailto:raymartin@aci-hq.com]
> Sent:	Wed 12/18/2002 2:42 PM
> To:	cocoon-users@xml.apache.org
> Cc:
> Subject:	RE: How do I read  files inside an Action?
> Sir,
>
> Just like any other file called from java.
>
> In the action class you would need:
>
> import java.io.File; // cocoon has some defaults - this could be
> one of them
>
> //nothing special here, just an example.  however, this directory is where
> cocoon places uploaded files by default.  make yours wherever
> your xml file
> is located.
> String currentPath = "C:/Program Files/Apache Group/Tomcat
> 4.1/work/Standalone/localhost/cocoon/cocoon-files/upload-dir/";
>
> // next three lines checks the directory for files and sets pointer to the
> first file in the directory (should put some checks around this)(could
> iterate through the list)
> File fileDir = new File(currentPath);
> File[] listOfFiles = fileDir.listFiles();
> String filename = listOfFiles[0].toString();
>
> File uploadDir = new File(currentPath);
> File theXMLfile = new File(filename);
> System.out.println("The director is: " + theResume.getParent());
> System.out.println("The file name: " + theResume.getName());
> long fileLen = theXMLfile.length();
> Long testThis = new Long(fileLen);
> int fileLength = testThis.intValue();
> FileInputStream fis = new FileInputStream(theResume);
> byte[] byteArray = new byte[fileLength];
> int cnt = fis.read(byteArray, 0, fileLength);
> fis.close();
>
> byteArray now contains the contents of theXMLfile.  this only works for
> ASCII files.  i do not have an example at my fingertips for Unicode.
>
>
> these are snippets from an action that i have performing.  if you need
> anything else, holler.
>
> Ray
>
> > -----Original Message-----
> > From: Chintalapaty, Sreedhar [mailto:schintalapaty@ptc.com]
> > Sent: Wednesday, December 18, 2002 10:00 AM
> > To: cocoon-users@xml.apache.org
> > Subject: How do I read files inside an Action?
> >
> >
> > Hi,
> >
> > Can some one point me to an example of how we can access an xml
> > file on the file system from a custom Action?
> >
> > TIA,
> >
> > Sreedhar
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>
>



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message