Pass Files As Arguments

I have several files and want to pass them as arguments to a Helper class for further processing. I put the public static void main (String arg[]) {} class and the Helper class in a package.
I got error messages "cannot resolve symbol" for:
1. variable XSLTransformHelper for if (!XSLTransformHelper.transform(xmlin, xslin, htmlout))
2. method close() for xmlin.close();
3. method close() for xslin.close();
4. method close() for htmlout.close();
I cannot spot the problems and my code can be seen below:
=====================================
package Transform;
import java.io.*;
public class XSLTransform {
public static void main(String[] args) throws Exception {
//Create a file object with the file name in the argument:
File xmlin = new File("c:/javaprj/RSS.xml");
File xslin = new File("c:/javaprj/RSS.xsl");
File htmlout = new File("c:/javaprj/RSS.html");
if (!XSLTransformHelper.transform(xmlin, xslin, htmlout))
System.err.println("Transformation failed");
else
try {
xmlin.close();
xslin.close();
htmlout.close();
catch(IOException e)
{System.out.println("closing file exception");}
=======================================================
=======================================================
package Transform;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class XSLTransformHelper {
public static boolean transform(String xmlFilename, String xslFilename, String resultFilename) {
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xmlSource = new StreamSource(new FileInputStream(xmlFilename));
Source xslSource = new StreamSource(new FileInputStream(xslFilename));
Transformer transformer = factory.newTransformer(xslSource);
Result result = new StreamResult(new FileOutputStream(resultFilename));
transformer.transform(xmlSource, result);
return true;
} catch (TransformerFactoryConfigurationError transformerFactoryConfigurationError) {
transformerFactoryConfigurationError.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
return false;
======================================================

I have several files and want to pass them as
arguments to a Helper class for further processing. I
put the public static void main (String arg[]) {}
class and the Helper class in a package.
I got error messages "cannot resolve symbol" for:
1. variable XSLTransformHelper for if
(!XSLTransformHelper.transform(xmlin, xslin,
htmlout))
2. method close() for xmlin.close();
3. method close() for xslin.close();
4. method close() for htmlout.close();
I cannot spot the problems and my code can be seen
below:
=====================================
package Transform;
import java.io.*;
public class XSLTransform {
public static void main(String[] args) throws
ws Exception {
//Create a file object with the file name in the
n the argument:
File xmlin = new File("c:/javaprj/RSS.xml");
File xslin = new File("c:/javaprj/RSS.xsl");
File htmlout = new File("c:/javaprj/RSS.html");
if (!XSLTransformHelper.transform(xmlin, xslin,
slin, htmlout))
System.err.println("Transformation failed");
else
try {
xmlin.close();
xslin.close();
htmlout.close();
catch(IOException e)
{System.out.println("closing file
losing file exception");}
=======================================================
=======================================================
package Transform;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class XSLTransformHelper {
public static boolean transform(String
ing xmlFilename, String xslFilename, String
resultFilename) {
try {
TransformerFactory factory =
y factory = TransformerFactory.newInstance();
Source xmlSource = new StreamSource(new
mSource(new FileInputStream(xmlFilename));
Source xslSource = new StreamSource(new
mSource(new FileInputStream(xslFilename));
Transformer transformer =
ansformer = factory.newTransformer(xslSource);
Result result = new StreamResult(new
mResult(new FileOutputStream(resultFilename));
transformer.transform(xmlSource, result);
return true;
} catch (TransformerFactoryConfigurationError
onError transformerFactoryConfigurationError) {
transformerFactoryConfigurationError.printStackTrace()
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
return false;
======================================================I observe that you pass Files as arguments of the method transform while this method is expecting Strings!!!!

Similar Messages

  • Is it possible to pass files as arguments to executable jars in windows?

    Hi,
    I've searched through the forums a bit and couldn't find any good info... basically, I'd like a user of my jar file to be able to drag and drop a file onto my jar file, and have the jar file process that file.
    Anyone know if this is possible? I'd like to have all the configuration done on my side, so that the users don't have to set up/modify their file extension -> program associations...
    I'm also looking into writing a DOS batch file to do that... but I guess that would be off-topic for this forum.
    Thanks in advance,
    KaJun

    Currently, Oracle 9iFS does not support referencing files
    with a BFile column. All files are stored as BLOBs.
    It would help us plan our future releases if you would explain
    why you wish to use BFile and keep your file content outside of
    the database.

  • Pass XML in argument tag in JNLP file

    Is there a way to pass an xml string in the <argument> tag. I tried to do it but I get xml parsing error. It seems that the xml becomes the child node when I pass that to the arguments tag. the CDATA also does not work. Has anyone done this successfully. thanks
    I am trying to pass somthing like
    <argument><Settings><URL>http://xxx.com</URL></Settings></argument>
    this is just an example I have also tried
    <argument>"<Settings><URL>http://xxx.com</URL></Settings>"</argument>
    this also errors out.
    <argument><![CDATA[<Settings><URL>http://xxx.com</URL></Settings>]]</argument>
    that does not work too.
    Please let me know if there is anything else I can try

    I've successfully used CDATA to embed HTML in an argument, on JDK 1.5 at least (not tried on others yet).
    Your CDATA closing section should be: ]]> Yours is missing the end bracket - if that's not an error in your post it's probably the cause of the XML parsing error.

  • Is there a way to pass files to a LV app in Mac OS X?

    There is an option in the Finder in Mac OS X to open files with the specified application. I tried it with my LV app, but unfortunately I haven't found any way to read out the filename passed to the app.
    (The Application/Command Line Arguments Property didn't work in this case.)
    Has anyone ever tried to pass files to a LV app in Mac OS X? I mean not in the command line but in the Finder.
    Thanks in advance

    Hi,
    When I understand this right - and as I am not so much of a MAC Expert - you want to do the following:
    1. You are in a file finder, where you can click on files an select: "open with ProgrammXY"
    2. That ProgrammXY should  be a LabVIEW App you created that can open files for Analysis.
    3. The LabVIEW App catches from somewhere the path-string and name of the file that was selected to be opened with your LabVIEWApp, like from some
    kind of property node or function.
    4. How to do that?
    I do not think that is possible, at least I do not know a way to do that in Windows so I doubt there is a way to do that in MAC OS.
    <<Anyway, it could even be an empty App, the main question is if it is even possible to get the filename in a LV App if we open it in Finder.
    When you cannot configure the Finder in a way so that he writes the file name as a command line parameter in the opening call .- exuse me if that is not MAC vocabulary - I do not see a way how to do this.
    Regards
    René

  • How to pass command line arguments to JWS app

    Hi,
    I want to pass command line arguments to my JWS application. However those arguments are dynamic (eg the username of the user who launched the app) and thus I can not use the argument tag of JNLP file. So what do I need to do in this case?
    Thanks.

    Well, if it's the username on your server systems you should probably include it in the jnlp: can pass it in the url, write once and remove jnlp href attribute, etc.., etc.. (a quick tour of this forum should suffice).
    If it's the OS username you should be able to retrieve it through system properties.
    Whatever it is, passing dynamic arguments means launching javaws through a shell or a shell script (bat if running on windows), so you won't be able to launch through autogenerated desktop and menu shortcuts.
    Anyway, you have two solutions:
    Clean one: associate an extension to your app and write those infos in a file named after that extension.
    Dirty one (always seen it work, but there's no warranty): javaws -open whateverParamYouLike yourAppURL.jnlp, will pass to your main method '-open' as args[0] and '+whateverParamYouLike+' as args[1]. I gotta admin I used it, but I had the most peculiar reason (my app needed another instance on a different JRE aware of being a secondary instance at startup time).
    Bye.
    PS: I'd really love dukes ;-)

  • How to run jar files with arguments?

    Hi everybody,
    Is it possible to run a jar file with arguments passed to its MAIN class?
    If yes can you help me on how to do it?
    Thanx

    I am in complete agreement with FahleE. I'll refine it a bit.
    On my machine (running RedHatLinux8.0) you can run the demos like this.
    1. open a console window
    2. go to the directory where the demo you wish to run, say, demo.jar, is located
    for instance for the SwingSet2-demo
    cd /usr/lib/java/demo/jfc/SwingSet2
    3. run the jar file
    java -jar demo.jar
    In order to run it windows style, ie, launching by double clicking, save these lines in a file called
    LaunchJar.sh
    cd /usr/lib/java/demo/jfc/SwingSet2
    java -jar demo.jar
    where demo.jar is the jar file you want to run.
    Right click on the LaunchJar.sh and go to the 'Properties' tab. Check the 'Execute' permissions for Owner/groups/others. You can also do the same thing by chmod command.
    Now double-click on the LaunchJar.sh file: your application should be launched.
    Palash.
    Please Note: It is important to set the path variable to your JAVA_HOME directory....
    Otherwise, instead of
    java -jar demo.jar, you will need to use the full path to your JAVA_HOME/bin directory like:
    JAVA_HOME/bin /java -jar demo.jar.
    Where JAVA_HOME is the directory where you have installed java. Typically it is usr/java or usr/local/java

  • Passing array as arguments

    im very new to java, dont know much about it.can any one please tell me how ot pass array or array list as a argument to a class

    this is my main class where it calls a readfile class to read contents of file
    import java.awt.List;
    import java.io.IOException;
    public class Sample {
    public static List alist = new List();
    public static void main(final String[] args) throws IOException {
    new Readfile().readFromFile("c:/sam.txt");
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.StringTokenizer;
    this is readfile class which reads from file having comma as a delimiter and store it in an array list.
    class Readfile {
    * Declaration of arraylist.
    static List alist = new ArrayList();
    public void readFromFile(final String filename) throws IOException {
    BufferedReader bufferedReader = null;
    // Construct the BufferedReader object
    bufferedReader = new BufferedReader(new FileReader(filename));
    String line;
    while ((line = bufferedReader.readLine()) != null) {
    // storing in to arraylist
    StringTokenizer st1 = new StringTokenizer(line, ",");
    while (st1.hasMoreTokens()) {
    alist.add(st1.nextToken());
    //here just im printing the elements from arraylist.
    for (int j = 0; j < alist.size(); j++) {
    System.out.println(alist.get(j));
    if (bufferedReader != null) {
    bufferedReader.close();
    //converting arraylist to array;
    String[] strArray = new String[50];
    alist.toArray(strArray);
    //passing array as argument
    Area area1 = new Area(strArray);
    area1.calc();
    area1.print();
    Here is the class for area
    class Area {
    String[] alist1 = new String[50];
    private int[] array = new int[50];
    private int[] array1 = new int[50];
    public Area(final String[] alist) {
    alist1 = alist;
    void calc() {
    * for (int i = 0; i < 2 - (alist1.length); i = i + 2) { array1[i] =
         (Integer.valueOf(alist1).intValue() * Integer .valueOf(alist1[i ]).intValue());
    * To print the Area.
    void print() {
    System.out.println("Area of Rectangles ");
    for (int i = 0; i < array1.length; i++) {
    System.out.println(array1[i]);
    im not sure how standard my code is .please guide me

  • Sqlldr - passing file as a param

    hi,
    here is what a line in first.sql looks like:
    ho sqlldr userid=usrname/passwd control=file1.ctl log=file2.log direct=true errors=10000
    where file1.ctl looks like:
    LOAD DATA
    INFILE 'file3.txt' "str '\n'"
    INTO TABLE table_name
    FIELDS TERMINATED BY '\t'
    TRAILING NULLCOLS
    (sno char(1000),
    salary INTEGER EXTERNAL)
    Now, if i want to pass file3.txt as a parameter to either first.sql or file1.ctl - how would i do that?
    thanks

    Hi,
    You can save the following sqlldr command in one shell script named first.sh
    sqlldr userid=usrname/passwd file=$1 control=file1.ctl log=file2.log direct=true errors=10000
    Please change your control file as below
    LOAD DATA
    INTO TABLE table_name
    FIELDS TERMINATED BY '\t'
    TRAILING NULLCOLS
    (sno char(1000),
    salary INTEGER EXTERNAL)
    And run the shell script first.sh by passing the source file as argument like below.
    ./first.sh file3.txt
    Note: This is not tested. Please try and let us know if you face any issues.
    Thanks,
    Karthik

  • Passing files in automator to a terminal command?

    I would like to know if something is possible: I've used automator to sort through a large number of files for specific traits using the 'Filter Finder Items' action. Can I then pass these files, one by one, into a terminal command?
    Specifically, I have a bunch of markdown files that I want to run through the markdown command in the terminal.
    Thanks for any help,

    automator has "run shell script" action. just add that action to the end of your wrokflow with the option to pass input as arguments.

  • Question about pass file name and path to file write adapter

    I need to pass file name and path to file adapter for write. I got partial answers from thread Re: Get File name using File Adapter , but seems InboundHeader_msg or outboundHeader_msg only takes file name, how do I pass file directory?
    since I still have to specify file format (like xxx_%xx%.txt) in the file adapter wizard. Will this name conflict with what the name defined in InboundHeader_msg ?
    Similarly, how can I pass a file name and path to a file synchread adapter?
    Thanks,
    Message was edited by:
    user531689

    Just overwrite the filename in the WSDL file that was generated

  • How to pass file reference to c

    Hi,
    I want to pass file reference pointer to a dll written in visual c++. How can i do that?

    What do you want to do with that reference in your C code? if you want to access it using OS File IO functions you have to be very careful! You should not mix LabVIEW nodes and OS platforms calls together. It's either one or the other.
    If you can guarantee that what you want to do is configure the Call Library Node (CLN) parameter to Adapt To Type. Then right click on the CLN and select "Create C Source Header" or something to that meaning. Save the resulting file to disk. Open it and copy the function prototype into your C/C++ file. There should be a parameter typed LVRefnum *. Now you can use the LabVIEW manager C function MgErr FRefNumToFD(LVRefNum refNum, File *fdp);
    You need to link your DLL with labview.lib in the cintools directory in order to be able to call the FRefNumToFD() function. The value in the fdp reference is the platform specific file handle, so for Windows this is a HANDLE.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • OCITerminate: Bad Pointer: 0x0397BC28 passed to free, argument 1.

    Using VS2005 SP1 and linking with oci.lib
    Bad Pointer: 0x0397BC28 passed to free, argument 1.
    Current Call Stack - Thread 0 [0x0630]
         C:\oracle\ora102\BIN\oracore10.dll!0x0003abba     
         C:\oracle\ora102\BIN\oracore10.dll!0x0003541a     
         C:\oracle\ora102\BIN\oracore10.dll!0x00055c02     
         C:\oracle\ora102\BIN\OraClient10.Dll!0x000aec95     
         C:\oracle\ora102\BIN\OraClient10.Dll!0x00005fc0     
         C:\oracle\ora102_server\BIN\oci.dll!0x0000dc5f     
    [MyCleanupFunc]
    Can my trouble com from what appears to be a mix of my C:\oracle\ora102_server\ and C:\oracle\ora102\ (client) libraries ?????

    I couldn't guarantee it, but it certainly is bad practice to mix them both. It's odd that your application would get through the rest of the OCI calls successfully with a mixed client library, but you should pick one or the other (client or server) to link against and make sure PATH is set accordingly at build-time.

  • Passing files into BPEL processes

    Hi,
    I was wondering if it is possible to pass files of different types (.doc, .jpg etc.) into a BPEL process. If so, are there any documentation and/or examples showing how to do this?
    Thanks

    in 2.0.11, the only way to pass files to BPEL processes is to use base64 encoding.
    we are looking at providing better support for binary attachment in the 10.1.3 Preview 1 release scheduled for March 05.
    Best,
    Edwin

  • Launching Air Captive runtime by double clicking file does not pass location in arguments

    I am trying to make my Air Captive Runtime Mac OS X app respond correctly when the user double clicks on a file type associated with the app.
    I have set up the invoke event listener to capture location of the file that the user has clicked to launch the app stored in the event.arguments variable.
    In the following simple test I just print out the length of the arguments passed in when the app is invoked. This is the behavior I am seeing:
    1. when I launch the app from the command line with 2 args,
    open test.app --args arg1 arg2
    I get "2"  as expected for the arguments length.
    2. If the app is already open and I double click a file with a type associated with the app. It correctly invokes the app and passes in the path to the file that was clicked. Length is 1 as expected and the content is the path to the file.
    3. However, if I just double click the same associated file when the app is not open, the app launches correctly, however no arguments are passed. Length is 0 and there is no way to know what file the user double clicked.
    here is code:
    var debugOutput = new TextField();
    addChild(debugOutput);
    NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
    function onInvoke(e:InvokeEvent):void
      debugOutput.text = e.arguments.length;
    Any thoughts on what might be going on?

    I have the same problem. i have tired AIRSDK 3.1 & 3.4, my app can run normal without Captive-runtime mode in my nexus s, But keep getting the message "unfortunately, (myappname) has stopped" when packed with Captive-runtime.

  • Passing -Xms -Xmx argument when launching a Jar file

    Hi
    My Java app is memory hungry and, so far, I have to start it with
    java -Xmx256m -jar myApp.jar
    I'm wondering if it's possible to embed "-Xms256m" into this .jar file
    so that I can simply start it by double-clicking on the myApp.jar file.
    Thanks
    Hui :)

    Well i had the same problem, and since now all answers i found were negative. A (not so good, but working) solution (at least for my needs)is here: http://forum.java.sun.com/thread.jsp?forum=54&thread=307731&start=0&range=30#1229424
    Any better solution (i am sure there is a lot) is wellcome...

Maybe you are looking for

  • CS5 or Elements for Drawing?

    hello everyone. I know this doesn't sound original but I have yet to find an answer so I came here. I am hoping to get a Wacom Bamboo Fun tablet soon and it includes Adobe Elements 8. I am an artist and browsing around places like DeviantArt i find t

  • Can I still backup my HD after s.m.a.r.t. failure?

    I have an early 2009 iMac. A couple weeks ago it began to act very stuttery and slow and then would eventually freeze. I booted into safe mode and was told the HD had problems and needed to be repaired. I booted from the osX snow leopard install disc

  • DB Link - OPEN_LINKS

    What does open_links parameter mean ? Say if the value is 4 and remote databases are A,B and C 1. Does it mean you can have only 4 concurrent sqls accessing a remote database (remote database A) 2. Does it mean you can have as many SQL's accessing "A

  • Why does my browser hang?

    Something really annoying is ocurring. I cannot figure out what makes this happen but, every so often certain web pages hang for at least 35 seconds and even up to a minute before the response is recieved and then the webpage is rendered. I have only

  • Jdev webservice and java.util.Collection

    Hi, i write a web service based on an stateless session EJB i have 2 method who return double and they work fine. But i have added a method who return a Collection and when i try to regenerate my web service i got a message error because the return t