How to create a inputstream without using the file operation
Hi friends
In my application, I have to create a Streamsource object using the below constructor:
public StreamSource(InputStream inputStream)
Construct a StreamSource from a byte stream. Normally, a stream should be used rather than a reader, so the XML parser can resolve character encoding specified by the XML declaration.
If this constructor is used to process a stylesheet, normally setSystemId should also be called, so that relative URI references can be resolved.
Parameters:
inputStream - A valid InputStream reference to an XML stream.*[http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/stream/StreamSource.html#StreamSource(java.io.InputStream) |http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/stream/StreamSource.html#StreamSource(java.io.InputStream) ]*
But for creating the inputstream, i am creating a tempory file, ie I am using fileinputstream.
import java.io.File;
import java.io.FileInputStream;
import java.io.StringReader;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class SourceConvertor
private static Source convertStaxToStream(Source request)
// here the argument to this method is StaxSource and the return type is StreamSource
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = null;
File fp = null;
FileInputStream fInp = null;
try
transformer = factory.newTransformer();
fp = new File("tempFile.txt");
transformer.transform(request, new StreamResult(fp));
fInp = new FileInputStream(fp);
} catch (Exception e)
e.printStackTrace();
return new StreamSource(fInp);
public static void main(String args[])
try
String message ="<author><name>Rai</name><book>GodOfSmallThings</book></author>";
Source original = new StreamSource(new StringReader(message));
Source converted = convertStaxToStream(original);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.transform(converted, new StreamResult(System.out));
catch (Exception e)
// TODO Auto-generated catch block
e.printStackTrace();
This is not at all a good aproach because evey time it is creating a new file.
So can anyone suggest a better aproach or idea or a simple code snippet so that i can create the inputstream without creating a temporary file.
Thanks in advance:
*[http://www.javamilestone.blogspot.com/ |http://www.javamilestone.blogspot.com/ ] *
Err, a StreamSource is a Source. Check the Javadoc. You can pass it directly to the transform.
Similar Messages
-
How to create a domain without using the root user in Sunone Server
Hi,
I am having one requirement to create a domain without using root user in sunone application server 8.1. Does any body know the solution?
Message was edited by:
SPBPHi,
If you are using file-based installation, you can install as non-root user and create domains as usual. You can use asadmin command available at <AS_INSTALL>/bin to do this.
ex: ./asadmin create-domain domaindir /tmp/justfortest adminport 4850 --adminuser admin domain_nonroot_test
Did you face any problem doing this in non-root. Unless you have write permissions in domaindir, you won't be facing any problem.
Hope this clarifies your question.
Thanks,
-Balaji. -
How to create window key without using the trillium option
Hi,
I am having some problems when trying to create using the window key generator module in ODI data quality.
I created a business data parser for cleansing my records. This had to pass thru 4 routines, the transformer, parser, window key generator and the matcher routines. The transformer and parser routines have run properly but they window key generator is asking me to specify the window key.( I created the rules for the window key. Like last 3 consonants of last name and 5 digits of some ID). But this is not getting accepted when i am running it and pops an error message.
I also do not have the trillium module integrated with ODI as of now.
Can anyone help me with this problem or anyone has faced the same situation and have tried a work around for it.
Please let me know.
Thanks,
ChapannaHi,
If you are using file-based installation, you can install as non-root user and create domains as usual. You can use asadmin command available at <AS_INSTALL>/bin to do this.
ex: ./asadmin create-domain domaindir /tmp/justfortest adminport 4850 --adminuser admin domain_nonroot_test
Did you face any problem doing this in non-root. Unless you have write permissions in domaindir, you won't be facing any problem.
Hope this clarifies your question.
Thanks,
-Balaji. -
How to create Oracle Alert without metioning the email address in To Field
Hi,
I just wanna know that how to create Oracle Alert without metioning the email address in To Field.
Please help thanks.If you don't enter anything in the email field, the alert email won't go out.
If you just want to test or if you plan to use the history, you can put a non-existant email there.
The alert will fire anyway.
Hope this helps,
Sandeep Gandhi -
Hello! I'm out of the country and all my iWeb information is on my computer at home. Now I need to make changes on the webpage... how can i do that without using the computer i made the page on? Thank you!!
iWeb uses the domain.sites2 files to store its assets.
You'll find it here :
~/Library/Application Support/iWeb/
where ~ is your Home directory.
If you take a computer with you, you have to store that file in the same location.
It's not different from taking documents with you if you want to edit them.
A solution is to remotely control your computer at home.
TeamViewer, LogMeIn, Apple Remote Desktop or any VNC application you can use, like "Chicken of the VNC". -
Can i create apple id without use the credit card?
can i create apple id without use the credit card?
I'm getting the same thing. I created a new Apple ID via the Internet (appleid.apple.com) When I go to my device to try to use it, I have to review it first and in that process, I'm asked for a credit card or iTunes gift card. There is NO 'none' option.
I work in a school district and we'd like employees to use their own apple ID for free apps which will allow them the freedom to explore apps without weighing down our tech dept with myriad requests for random apps. I deal with a broad demographic and many users are suspicious of putting personal credit card info on an Internet-based account.
However, it appears they are locked out of the store unless they have some form of payment on file. Even if they enter a gift card, what happens when it's used up? Will they get locked out of the store if they don't have a balance?
Anyone have a work around? If not ... APPLE Please update your support materials to explain this, or fix the bug.
Thanks! -
How to reference a class without using the new keyword
I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
c.getFirstName();quedogf94 wrote:
I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
c.getFirstName();No.
Using new does not erase anything. There's nothing to erase. It's brand new. It creates a new instance, and whatever that constructor puts in there, is there. If you then change the contents of that instance, and you want to see them, you have to have maintained a reference to it somewhere, and access that instance's state through that reference.
As already stated, you seem to be confused between class and instance, at the very least.
Run this. Study the output carefully. Make sure you understand why you see what you do. Then, if you're still confused, try to rephrase your question in a way that makes some sense based on what you've observed.
(And not that accessing a class (static) member through a reference, like foo1.getNumFoos() is syntactically legal, but is bad form, since it looks like you're accessing an instance (non-static) member. I do it here just for demonstration purposes.)
public class Foo {
private static int numFoos; // class variable
private int x; // instance varaible
public Foo(int x) {
this.x = x;
numFoos++;
// class method
public static int getNumFoos() {
return numFoos;
// instance method
public int getX() {
return x;
public static void main (String[] args) {
System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
System.out.println ();
Foo foo1 = new Foo(42);
System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
System.out.println ("foo1.x is " + foo1.getX ());
System.out.println ();
Foo foo2 = new Foo(666);
System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
System.out.println ("foo1.x is " + foo1.getX ());
System.out.println ("foo2.numFoos is " + foo2.getNumFoos ());
System.out.println ("foo2.x is " + foo2.getX ());
System.out.println ();
} -
RPM - How to re-process prices without using the front end.
Hi all,
There is a way of re-processing prices without using the front end? For instance, using the front end, a new clearance is created state in rpm_clearance ‘pricechange.State.conflictCheckforApproved’ and changed for ‘pricechange.State.worksheet’ after the conflict check.
Now, I want to re-process the same clearance without using the front end. I’ve tried to change again the STATE to ‘pricechange.State.conflictCheckforApproved’ but no success. Any suggestions?
Thanks in advance.
RegardsCan you please attach your VI?
Prashanth N
National Instruments -
How do i install opensolaris without using the virtual box??
hi.
i am new to solaris
i am currently using a windows XP OS
i got down the opensolaris cd from SUN
how do i install opensolaris without using a virtual box ?The OpenSolaris CD is a "Live CD". You can boot off of the CD, and either run the OpenSolaris operating system directly, or you can select the "Install" icon on the LiveCD desktop. You can find full instructions here: http://dlc.sun.com/osol/docs/content/IPS/getst1.html
Do you want to keep your Windows OS on the disk? If so, then you want to follow the instructions for partitioning your disk (unless you already have a spare partition).
-- Alan -
How to install snow leopard without using the dvd drive?
Is it possible to install snowleopard without using the dvd ? i have a macbook and i have unfortunatly broken the cd and dvd player..
Yes you can.
How to use Migration Assistant:
http://support.apple.com/kb/HT4889?viewlocale=en_US
http://support.apple.com/kb/HT4413?viewlocale=en_US
http://support.apple.com/kb/TS1963 -
How to create a simple app using the MVC approach?
Hello gurus i'm trying to learn the SAPUI5 and i'm trying to create a simple app using the MVC i created the app and trying to add a lable to the view but there is nothing appear when i run it the code for the HTML page
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_mvi" theme -->
<script>
sap.ui.localResources("mytestapp");
var view = sap.ui.view({id:"idshell1", viewName:"mytestapp.shell", type:sap.ui.core.mvc.ViewType.JS});
view.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
the code for the view
sap.ui.jsview("mytestapp.shell", {
/** Specifies the Controller belonging to this View.
* In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
* @memberOf mytestapp.shell
getControllerName : function() {
return "mytestapp.shell";
/** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
* Since the Controller is given to this method, its event handlers can be attached right away.
* @memberOf mytestapp.shell
createContent : function(oController) {
var oLabel = new sap.ui.commons.Label("l1");
oLabel.setText("Test label");
oLabel.placeAt("content");
i dont know what is wrong or if i should use a container to display my controls
any help will be appreciated
thanks in advanceHi,
Instead of oLabel.placeAt("content"); use return oLabel;
so it will as below,
createContent : function(oController) {
var oLabel = new sap.ui.commons.Label("l1");
oLabel.setText("Test label");
return oLable;
Regards,
Chandra -
Create a entity without using the DBObjectName/Datasource tag in Entity.xml
Hi,
I am using Jdev11.1.13 version
In our application we are trying to implement the custom framework classes for tuxedo calls.
Before we are implemented(Tuxedo calls) using the Datasource entry in Entity.
but right now we have to implement tuxedo calls without using the datasource approach.
can anyone suggest
Thanks in adv
RajCheck out http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcadvvo.htm#sm0341
Timo -
How to start a BPEL Process using the File Adapter
Hi
I would like to automatically start a BPEL Process when I store a file in a specific directory. Can this be done using the File Adapter?.
Regards,
Néstor BoscánYes, there are samples of how to do this in the BPEL samples directory.
-
How to configure proxy services to use the file transport?
Hi,
I have configured a proxy service to poll for files in the specified folder. And it is configured to use the file transport.
At runtime, I'm getting the follwing exception -
<Apr 27, 2012 4:08:28 PM GMT+05:30> <Error> <WliSbTransports> <BEA-381602> <Error encountered while polling the resource for the service endpoint ProxyService$ServiceTypes_SB$BinaryService: javax.naming.NameNotFoundException: While trying to lookup 'wlsb.internal.transport.task.queue.file' didn't find subcontext 'wlsb'. Resolved ''; remaining name 'wlsb/internal/transport/task/queue/file'
javax.naming.NameNotFoundException: While trying to lookup 'wlsb.internal.transport.task.queue.file' didn't find subcontext 'wlsb'. Resolved ''; remaining name 'wlsb/internal/transport/task/queue/file'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
Truncated. see log file for complete stacktrace
Request help to resolve this.
Thanks in advance.
Regards
Shyam.VOnly the business service would rely on the JMS queues, which in turn would trigger an MDB. I have tested the business service and it works fine.
The problem is only with the polling part of the proxy service.
Regards
Shyam.V -
How to create a smart form using the purchase order
hi everybody............
i have created one purchase order, i want to print that PO using smartforms rather than scripts. how can i do it, can anyone help me out in solving the issue. i am using the version sap 4.7
Edited by: mhyderali on Aug 21, 2009 4:08 PMHi,
Before answer your question few things i would like to kno:
1. currently is there any script is printing while displaying output.
2. do u allready hae a smartform or you are going to develop a smartform.
3. if you dont have a smartform and there is a script attached then you can convert script into smartform and then you can change in the smart form accordingly.
4. after devloping a new smart form or converting script into smartform what you need to do is go to V/83 transaction give Output Type which is associated with script and Application area (for purchase order i.e. EF). then press ok screen will display here you can change the name of your form name under the form column.
6. if you dnt have the Output type then you need to create a output type for the purchase order.
Please let me know if you have still some question.
Thanks
Narendra
Maybe you are looking for
-
ITunes 7 won't add more than one file at a time
Hello everyone. I have a weird problem with iTunes 7.0.2. Every time I try to add multiple files to the iTunes library using the Add File To Library feature, it doesn't do anything. Adding one file at a time is possible, but tedious. Adding multiple
-
One JSP Coded in JSTL with an Action Link and a Form
My JSP written in JSTL with an action link works fine. The checkboxes are well recognized ( I have a "form" specified in both the action mapping and form bean). <%@ page import="......common.pojo.user.User" %> <!-- Create a variable in scope called u
-
HT5312 How can I get an activation locked phone to its original owner?
I recently purchased an iPhone 5 on eBay that was locked with the apple logo on it (As told by the seller who said he purchased it from someone else. So I had expectations of a possible Activation lock on the phone). When I reset the phone, I found
-
CProject and Virtual Room Integration
Hi, I am having some issues trying to integrate cProjects with Virtual Rooms from EP. Some questions: - In creating the http connection to the external server, where can I get the information for target host and port? Is this simply the EP host an
-
Muy buenas tardes estimados El motivo del presente es que en la siguiente query SELECT T0.FatherNum, (SELECT Y.AcctName FROM OACT Y WHERE Y.AcctCode = T0.FatherNum) 'Nombre Cuenta', SUM(T1.Debit - T1.Credit) 'Saldo' FROM OACT T0 INNER JOIN JDT1 T1 ON