How to create File object from InputStream
Hi everybody
Can I know a way to create a File object from InputStream object
Here's my code:
URL url = loader.getResource(xsdFile); //Thats a schema file..not to worry
InputStream istream = url.openStream();
Now from that 'istream' I need to build File object.
Thank you all
didn't know fileinputstream was made to read url objects ; in the doc, it just says "A FileInputStream obtains input bytes from a file in a file system." ; according to me, website is something outside the filesystem, but i could be wrong
edit: thought from the beginning it was all about FILEinputstream whereas it just says "inputstream" in the post ; my bad, it's still early in the morning here X)
Similar Messages
-
Creating File objects from all files in a folder.
Hi, I'm not too brilliant of a programmer, so this may be an obvious one that I could find in the API.
My goal is to compare files for similarities and then give some output, that's not too important.
My question is: How do I create an array of File objects from a folder of *.txt files, without creating each individually? Is there a way to simply get all the files from the folder?
File I/O is still pretty new to me. If I didn't give a good enough explanation, please say so.
Thank you very much!Note by the way that a File represents an abstract pathname, the idea of a file as a location. It doesn't specify the file's contents, nor does it require that the file it represents actually exists. A better name might be "theoretical file" or "directory listing entry".
So getting a whole bunch of File objects is itself perhaps not necessary (although it could be useful).
To expand on reply #1, look for File methods whose names start with "list". -
Create File Object from a remote file
Hi,
I would like to know about how to create a new File object from a file in a remote machine, it is a web application, i have the remote route of the file, and if I need the ip of the remote machine, I would like to know how to get it too.
File fileobject = new File(�What do I have to put here or before or whatever?);
Thank you very much.
J.First, from the technical point of view you can't create a File object unless it's a file on the computer where the code is running. It doesn't matter if you have an IP address or something, if you haven't mapped a drive to it you can't create a File object.
But more importantly, you can't just reach out from your server and grab a file from the client's computer. That's an obvious security violation and if you didn't realize that you shouldn't be designing web applications yet. If you want a file uploaded then you have to provide the client with an HTML form where they select a file to be uploaded. -
How to create and object from an arrayList
Hi I want to create an object from an arrayList.
here is my code...
BillingQueryParam billingQueryParam = new BillingQueryParam();
/*This BillingQueryParam and billingItemManagerActionForm has getter and setter method for following attributes.
private int billingItemId;
private String[] paramName;
private String[] defaultParamValue;
List billingQueryParamList = new ArrayList();
for(int i = 0; i < billingItemManagerActionForm.getParamName().length; i++) {
billingQueryParam.setParamName(billingItemManagerActionForm.getParamName());
for(int i = 0; i < billingItemManagerActionForm.getDefaultParamValue().length; i++) {
billingQueryParam.setDefaultParamValue(billingItemManagerActionForm.getDefaultParamValue());
billingQueryParam.setBillingItemId(billingItem.getBillingItemId());
billingQueryParamList.add(billingQueryParam);
System.out.println("****** ArrayList Size-->"+billingQueryParamList.size());
for (Iterator iter = billingQueryParamList.iterator();iter.hasNext();) {
billingQueryParam = (BillingQueryParam)iter.next();
System.out.println("****** BillingItemId-->"+billingQueryParam.getBillingItemId());
System.out.println("****** Param Name-->"+billingQueryParam.getParamName()); //printing an array of paramName
System.out.println("****** Default param value-->"+billingQueryParam.getDefaultParamValue());
}Here after iterating this list I want to create an object of billingQueryParam which contains a single value of itemId, paramName,paramTypeId and defaultParamName and I want to persist this object in database.
Please help...!!!
ThanksNow this is too much.. Do i need to tell this thing to u as well. How did u come to this forum?
Can't u see link to Java programming forum at the top. -
How to creat COM object from dll file?
Hi,
I tried to read about this topyc, but I didn't found eny example that creat
COM object. I downloaded jacob.jar
then I writed:
ActiveXComponent ax = new ActiveXComponent("C:/MyJava/deploy/SMSCom.dll");
Object SMSObj = ax.getObject();
I get error (I put jacob.jar with all athers jars, I don't know way this erre)
Exception occurred during event dispatching:
java.lang.UnsatisfiedLinkError: no jacob in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.jacob.com.Dispatch.<clinit>(Dispatch.java)file name: SMSCom.dll
object name: SMSSender
In VB this is the code:
Object SMSObj = CreateObject("SMSCom.SMSSender");
SMSObj.password = pass;
SMSObj.Username = name;
SMSObj.Source = phone;ThanksIn Eclipse:
1- To include jacob.jar for compile / run:
Choose the Java perspective, then in the Package Explorer right-click on the project and choose Properties.
Select Java Build Path from the left pane then the Librairies pane from the right.
Click on Add External Jars button and select the jacob.jar file then click Open then Ok.
2- To make jacob.dll and SMSCom.dll "visible" for run:
Open your Debug (or Run) Java application configuration (the one for your project's main class).
Select the Environment pane then click on Select button.
Select Path and click on Ok button.
Then re-select Path and click on Edit button.
Add the two appropriate folders for jacob.dll and SMSCom.dll in the Path and click on Ok then Apply.
Regards -
Create file object from xml file in different package
I have my java class which is in a package...edu.xx.proj
It contains the following
File f = new File("formats.xml");
My xml file is in the package edu.xx.proj.xml
How do I get the file object for my xml file?
Ultimately I want that once the jar is shipped .. The path of xml file shld be independent of my OS path... it can only lookup the package path..
I will really appreciate it if someone can throw some input as to how to resolve this issue..
Thank youI have my java class which is in a
package...edu.xx.proj
It contains the following
File f = new File("formats.xml");
My xml file is in the package edu.xx.proj.xml
How do I get the file object for my xml file?
Ultimately I want that once the jar is shipped .. The
path of xml file shld be independent of my OS path...
it can only lookup the package path..
I will really appreciate it if someone can throw some
input as to how to resolve this issue..
Thank you
InputStream inputStream = getClass().getResourceAsStream("xml/formats.xml");
/* OR */
URL url = getClass().getResource("xml/formats.xml");hth -
How to create value objects from xml
I am receiving xml back from my web service ( e4x ). I am
trying to figure out how to create a value object without having to
manually fetch each value in the value objects constructor. I am
using introspecton in my Java web service to do this. Is there such
a thing in Action Script?
Anyone done this before that can share some code???? Any help
would be very much appreciated.That's twice now I've heard that. lol.
I am using Cairngorm and I suppose out of ignorance perhaps,
I am using VO's. So my web service would return an Object Proxy and
I have some code that could create objects dynamically from the
results. The objects had to be simple of course and now they are
becoming more complex thus the need to change to e4x instead of
objects.
So now I am trying to convert the xml result into the desired
VO to be used throughout the rest of the application. I'm not sure
how to use Cairngorm without the VO's they are tied to everything.
Are you familiar with the architecture? Your thoughts? -
How to get File object from Document Object . ?
In conventional Dom Parsing we pass file to DocumentBuilder to get Document Object .
File file = new File("c:\\MyXMLFile.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file); // gOT Document here . My problem is how do i get File object back from Document . If i have Document object with mi.
Please consider above code as example i dont have File object in my code . i am using Xhive DB API where i get Document directly from API method .
I need to convert this Document to File to get size of file
Please suggest solution on this
Edited by: AmitChalwade123456 on Dec 5, 2008 6:10 AMHello Guys any views on this topic
-
How to Create file link from dynamic table.
Howdy -
I have MySQL database over PHP containing a simple table that lists a group of documents, including their file system address (contained within the site).
I've successfully created a recordset showing this table, and attached that to a dynamic table on a .php page. The display is correct, except I can't get the column contents to link to the document. The column just shows the text (title) of the document.
I've consulted article tn_15364 (http://kb2.adobe.com/cps/153/tn_15364.html), but that doesn't seem to work...
Any thoughts would be appreciated. I'm sure this is pretty simple, but I'm coming up snake eyes.
Charles AndrewsTo clarify:
My site has a folder where uploaded files (.doc, .xls, .pdf, etc.) are stored after having been uploaded by a user. During this upload process, the location of these files is stored, along with other identifying data, in a simple database table.
I have a dynamic table created in Dreamweaver that pulls from this database, listing the document name, etc. I would like the document name shown in a column to automatically link to the actual file so a user could just click on it and open the file.
I hope I'm not making sound more complicated than it is -
Thanks,
CWA -
How to create Activex object for my Visual C++ object
Hi,
I am working on development on Acrobat 9.0 SDK. I am facing problem is that I can compiled Visual C++ source code to an api. I can test functions on this api on Acrobat 9.0 windows, but I could not test it on IE web browser, because I don't know how to create Activex object from my Visual C++ source code or its api.
I read Acrobat 9 SDK document and found under C:\Acrobat 9 SDK\Version 1\PluginSupport\Tools\Visual Studio App Wizard has two files: Acro9PIWizInstaller.msi and setup.exe. I am not very sure those file are the key to help me to create Activex objects for my api. Are they the one I need to create Activex object? If not, could you please advise me how to create Activex object for my api or C++ codes.
Thanks a lot for any of your comments or advices.
ThaiHi lrosenth,
Thanks a lot for your information.
My question is, on Javascript how do I call a function from .api. Below is my very simple test.
I got a function on BasicPlugin.cpp under C:\Acrobat 9 SDK\Version 1\PluginSupport\Samples\BasicPlugin. See below.
I added BasicPlugin.api on C:\Program Files\Adobe\Acrobat 9.0\Acrobat\plug_ins
ACCB1 int ACCB2 MyPluginCommand() {
int num = 5;
return num;
On my HTML file, I create an <Object> below:
<OBJECT id="acrobatapp"
classid="clsid:85DE1C45-2C66-101B-B02E-04021C009402">
</OBJECT>
<OBJECT id="acrobatpdf"
classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" >
<Param name="SRC" value="http://www.adobe.com/devnet/acrobat/pdfs/acrobat_digital_signature_appearances_v9.pdf">
</OBJECT>
On my Javascript. I call function MyPluginCommand() as below, but it is not working. How do I call function MyPluginCommand() on Javascript?
var acrobatapp= document.getElementById("acrobatapp");
var num= acrobatapp.MyPluginCommand();
alert(num);
Thanks for your support,
Thai -
How to read appended objects from file with ObjectInputStream?
Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
import java.io.*;
class Fio
public static void main(String[] args)
try
if (args[0].equals("w"))
FileOutputStream fos = new FileOutputStream(args[1], true);
ObjectOutputStream oos = new ObjectOutputStream(fos);
for (int i = 2; i < args.length ; i++)
oos.writeObject(args);
fos.close();
else if (args[0].equals("r"))
FileInputStream fis = new FileInputStream(args[1]);
ObjectInputStream ois = new ObjectInputStream(fis);
for (int i = 0; i < fis.available(); i++)
System.out.println((String)ois.readObject());
fis.close();
else
System.out.println("Wrong args!");
catch (IndexOutOfBoundsException exc)
System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
catch (IOException exc)
System.out.println("I/O exception appeard!");
catch (ClassNotFoundException exc)
System.out.println("Can not find the needed class");How to read appended objects from file with ObjectInputStream? The short answer is you can't.
The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
Not trivial, but that's how you'd do it. -
Dynamically create Value Objects from XML file
Hi
I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.
-
How do I create an object from a filename?
I'm traversing directories and storing a list of files in a File array. Then I traverse the array looking at the extension of the file. If it is .java then I would like to instantiate it as a class so that I may pass the new object to another function which will examine its methods. I've tried Class.forName(file.getCanonicalPath()) and it throws a ClassNotFound exception. How can I create an object from a valid filename, please?
Rick_Avlonitis wrote:
If it is .java then I would like to </snip>.java files contain source code, they can't be "instantiated". Class.forName() takes a classname as parameter, i.e. "mypackage.MyClass". A class name is not a file name, and it doesn't have an extension. As stated in the other reply, you'll need to have the class on your class path. -
How to create Inbound Idoc from XML file-Need help urgently
Hi,
can any one tell how to create inbound Idoc from XML file.
we have xml file in application server Ex. /usr/INT/SMS/PAYTEXT.xml' we want to generate inbound idoc from this file.we are successfully able to generate outbound XML file from outbound Idoc by using the XML port. But not able to generate idoc from XML file by using we19 or we16.
Please let me know the process to trigger inbound Idoc with out using XI and any other components.
Thanks in advance
Dora ReddyHi .. Did either of you get a result on this?
My question is the same really .. I am testing with WE19 and it seems SAP cannot accept an XML inbound file as standard.
I see lots of mention of using a Function Module.
Am I correct in saying therefore that ABAP development is required to create a program to run the FM and process the idoc?
Or is there something tht can be done with Standard SAP?
Thanks
Lee -
How do I move objects from other package to a newly created one?
How do I move objects from other package to a newly created one?
Thanks!Dear Anthony Pham ,
for changing objects from one package to another package
open that object for example Report
open the report and than click GOTO select OBJECT DIRECTIORY ENTRY
than it will open a popup in that popup click the change and give the new package
Thanks
Surendra
Maybe you are looking for
-
I've been using a Panasonic HDTV as my G5's monitor for a while but the only drawback so far is the screen stretches beyond the visible edge... not by much, but things like the clock in the upper right are cut in half. I'm trying to figure out if it'
-
Upgrading from Snow Leopard to Yosemite
Hello, Long-time user of the forums, first-time poster (such a fantastic wealth of knowledge here!). One question prior to installing Yosemite: Does anyone have any experience installing from Snow Leopard to Yosemite - ideally with a Macbook Pro 15-i
-
Please i need help
-
Sharing Airport Extreme with attached HD over WAN to Windows
So I've never gotten this to work. I have three external HD's attached to my airport extreme, the extreme is set to share over WAN, and any Mac can connect with zero problem using AFP. However, I've never had a Windows computer connect successfully u
-
Can I disable installing extensions for a large group of computers on a domain
I have a large number of computers on a network. I have users who are installing addons to bypass a webfilter. Is there a way to disable installing addons via group policy or some other remote management?