File explorer java code
Hi, I need to write a windows-explorer-like File Explorer panel. Could anyone point to me some sample code?
Thanks,
autogoor
I did not try it yet, but you could use the NetBeans platform as a base for your application (includes file access via file explorer).
Source code is available at:
http://www.netbeans.info/downloads/download.php?a=b&p=2
Or, maybe, a simple JFileChooser would do it ?
Similar Messages
-
Run chm help file through java code
hello,
would you tell me how can i run a help.chm file using java code. i am trign this but no luck.
first try
Process pp=run.exec("C:/Program Files/Internet Explorer/IEXPLORE.exe ./res/bobftphelp.chm" );
Second try
Process pp=run.exec(" ./res/bobftphelp.chm" );
It run fine a help.doc file but not help.chm file.
please help me
Thanka in advance
Ravi CharanThe second address given to that function, does it relate to the class that its being called from? cause i've got
Runtime.getRuntime().exec("C:\\WINDOWS\\hh.exe .\\HelpFile_9_3.chm" );where HelpFile_9_3 is in the same folder as my class, but it won't work. Can anyone help?
Also, can you search within a chm file from Java? If I get that above code working, I presume it'll open the help file to the main page. I'd like to search within that document for a word or phrase - possible?
Thanks!
Edited by: Pulkse.co.uk on Sep 10, 2008 8:18 AM -
Generation of xml file from java code
hi,
I want to manipulate data in a xml file with java code.I have read data from xml file and also changed it. But i am unable to covert it again in xml file from java code. Can you please tell me how i can do this?Let me know which parser are you using currently for reading xml files so that i assist you. For now, you can refer to STAX Parser API under this link
http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP3.html -
How to call a .bat file from java code?
How to call a .bat file from java code? and how can i pass parameters to that .bat file?
Thanks in advancethanks for ur reply
but still i am getting the same error.
I am trying to run a .bat file of together tool, my code looks like below
import java.lang.Runtime;
import java.lang.Process;
import java.io.File;
class SysCall{
public static void main(String args[]){
String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
//String path="D://Borland//Together6.2//bin//Together.bat ";
Runtime r= Runtime.getRuntime(); //Declare the system call
try{
System.out.println("Before batch is called");
Process p=r.exec(cmd);
System.out.println(" Exit value =" + p.exitValue());
System.out.println("After batch is called");
/*can produce errors which must be caught*/
catch(Exception e) {
e.printStackTrace();
System.out.println (e.toString());
I am getting the below exception
Before batch is called
java.lang.IllegalThreadStateException: process has not exited
at java.lang.Win32Process.exitValue(Native Method)
at SysCall.main(SysCall.java:17)
java.lang.IllegalThreadStateException: process has not exited -
How to copy a file from Java code
I have written a file through Java code in folder, say, "A". Now, I want a copy of that file exactly the same in some other folder "B". How, it can be done?
http://java.sun.com/docs/books/tutorial/essential/io/streams.html
-
Starting exetutable java file from java code
Hi I was wondering how I can start a executable java file from java code?
thanksHi Mkaveli,
Yes, it's possible. If you have a JAR executable, you've just to call the main method of its starter class. For a simple executable class, just call its main method.
This way :
SomeStarter.main(null); // if there's no argumentSmall precision : the executable JAR or class must be specified in the classpath of your application. -
How to modify an existing xml file from java code.
Hi
I have worked on creating a new xml file from java code using xmlbeans.But if i try to modify an already existing file using java code I am unable to get errorfree xmlfile.
For example if xml file(studlist.xml) is as below:
<?xml version="1.0" encoding="UTF-8"?>
<StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
<Student>
<Name>ram</Name>
<Age>27</Age>
</Student>
<Student>
<Name>sham</Name>
<Age>26</Age>
</Student>
</StudentList>
Now suppose i have set name to victor using student.setName,
and set age to 20 using setAge from javacode,
the new xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<StudentList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\kchaitanya\xmlprac1\abc\Studlist.xsd">
<Student>
<Name>ram</Name>
<Age>27</Age>
</Student>
<Student>
<Name>sham</Name>
<Age>26</Age>
</Student>
</StudentList>
<Student>
<Name>victor</Name>
<Age>20</Age>
</Student>
As observed this is not a valid xml file.But how can i modify without any errors?I know it's an old post, but I found this while doing a google search for something else, and don't like to leave it un-aswered
Just in case anyone has a similar problem... In this case the new elements have been appended outside of the root element
What you need to do is first get the root element and then append the new children to that, there are several ways of getting the root element, which depend on what you want to do with the elements you get back here's a simple (incomplete) way.
// gets the root element of the specified file (code not shown)
Element rootElement= new SAXReader().read(file).getRootElement();Then just append the new elements as below (this is non-generic code and would need to be modified for your situation)
// write a new student element
Element student = document.createElement("Student"); // creates the new student
rootElement.appendChild(student); // ***appends it to the root element***
Element name = document.createElement("Name"); // creates the name element
name.appendChild(document.createTextNode("Fred")); // adds the name text to the name element
student.appendChild(name); // appends the name to the student
Element age= document.createElement("Age"); // creates the age element
age.appendChild(document.createTextNode("26")); // adds the age text to the age element
student.appendChild(age); // appends the name to the studentThen flush ya buffers or whatever and write the file
Edited by: Dream-Scourge on Apr 23, 2008 11:10 AM -
Running bat files in java code
Hi,
I am trying to run a .bat file within java code like this.
Runtime.getRuntime().exec("c:\\Test.bat");
but no success. Could you please suggest how to run .bat file or simply a
DOS command from java code.
thanx in advance
Deepak Garg.try this...
n reply whether it worked or not......
import java.util.*;
import java.io.*;
import java.net.*;
try
Runtime runtime = Runtime.getRuntime();
Process process ;
process= runtime.exec("./temp_install");
//code to print command line replies
InputStream stderr = process.getInputStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while((line=br.readLine())!=null)
System.out.println(line);
catch(Throwable t)
t.printStackTrace();
} -
How do I produce an excel file using java code
How do i produce an excel file using java code.
If it is possible would ne one have ne source code as an example.
I have tried looking up information on outputing the information to a *.csv file but unfortunality i have had no luck in finding any information. To be exact ne source code.
Thanks
LeeThat's what I use and I'd be the first to admit that it's very messy. But it works. Go use Google and see what else you can find.
-
Split XML in Multiple XML files with Java Code
Hi guys , i have following xml file as input ....
<?xml version="1.0" encoding="ISO-8859-1"?>
<T0020
xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>2009-09-01T00:00:00</DATE_TIME>
<TZ>CT</TZ>
</TRANSACTION>
<IRP_ACCOUNT>
<IRP_CARRIER_ID_NUMBER>274845</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>AR</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>55002</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>100</IRP_STATUS_CODE>
<IRP_STATUS_DATE>2007-11-06</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>2009-08-03</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>A P SUPPLY CO</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>1400 N OATS</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>71854</ZIP_CODE>
<COUNTY>MILLER</COUNTY>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
<IRP_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>P O BOX 1927</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>75504</ZIP_CODE>
<COUNTY/>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>
</IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
and i want to take this xml file and split it into multiple files through java code like this ...
File1.xml
<T0020>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
File2.xml
<T0020>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
like wise...
Each xml file contain maximum 10 or 15 IRP_ACCOUNT.
Can somebody please help me ? How can i do it with stax like start element and all ?
thanks in advance.Ah, sorry, strike that. You want multiple files. I think the easiest way is to simply parse with DOM. [http://www.w3schools.com/xpath/default.asp] . And here [http://www.w3schools.com/xpath/default.asp].
You can output the various XML elements using a PrintWriter or creating a separate DOM document for each file you want to create and serializing that.
- Saish -
Run batch files through java code
Hi All
I need to run a batch file using java code . I am not getting any error, but also no output. Can someone let me know the problem with my code.The code i am using is
import java.io.*;
public class batchtest {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
Process p= null;
String line;
try{
p = r.exec("cmd /c testBatch.bat");
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
input.close();
System.out.println("running...");
}catch(Exception e)
e.printStackTrace();
}Maybe this helps:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
How can I using functions implicit in dll file in java code ?
How can I using functions implicit in dll file in java code ?
I'm developing a program that interfacing with fingerprint hardware.
I have the finger print already, and I have to the SDK that have all functions for managing this fingerprint.
These SDK functions are represented in dll files.
I want to know how can I use these functions in java code .
I looked on this link of sun forums :
http://forum.java.sun.com/thread.jspa?threadID=305171&messageID=1215613
but I don't Understand the meaning of native code.
Thanks for help.please please please please please please please please help me:
After reading a lot of articles, tutorials, and overviews about JNI (Java Native Interface)
I found that these steps
1. Develop the Java code
2. Compile the Java code to a class file
3. Generate the header file
4. Implement the native method
5. Create the shared library or DLL
6. Run the Java program
Is the common steps in JNI development
The most powerful link was
http://java.sun.com/docs/books/jni/html/start.html
and
http://www.netbeans.org/kb/55/beginning-jni-part2.html
and the pdf oh this link
http://www.ibm.com/developerworks/edu/j-dw-javajni-i.html requiring IBM registration to download it.
But I have already the DLL, and want to the stright forward way to use its functions by java code only.
I don not to write any C++ code .
Is this possible???????????????????????????????
The name of these dll is �zkemsdk.dll�
It developed by ZKSOFTWARE company for managing a finger print �NP1500A�of
http://www.napcogulfsecurity.com/finger_print.asp
thanks for help -
OpenScript/How to add .jar file to Java Code in relative path
Hi all,
I want to add a .jar file which can be executed separately (like "java -jar A.jar") to my recorded Java Code.I've read this wiki http://everest2.us.oracle.com/wiki/Generic_JAR_Project about how to add a .jar file to "Assets", however, I cannot figure out how to use the .jarr file in Java code,I mean , how to get this .jar file like the method the databank added in "Assets"?
Things I did are as followed:
1.Execute my .jar file in OpenScript Java code with absolute path like this:
String cmd = "C:\Users\A.jar";
Runtime.getRuntime().exec(cmd);
This does work, but must set a absolute path in Java code like "C:\User\A.jar" ,which is not the workaround I want (I need my scripts can be run on other machines).
2.Try to get its current path with following codes:
File directory = new File(".");
String currentPath=directory.getCanonicalPath();
However,though this can get its absolute path (which is the the project path) in Eclipse like "C:\Users\Workspace\testProject", this only gets "C:\OracleATS\openScript" in OpenScript.
I thought to copy my .jar file to the project path , got its current path in java code first,then can know the path of .jar file, but this workaround failed because of the above reason.
I notice that in the "Assets" there are "Databanks","Object Libraries","JAR Files","Scripts". Since the databanks and scripts that added to "Databanks" and "Scripts" can be got or run in Java Code like:
*getDatabank("DatabankName").getNextDatabankRecord(); String data = eval("{{db.DatabankName.data}}");*
*or getScript("ScriptName").run();*
*Is there a method to get and run the jar file added to "Assets\JAR Files" like the above?*
Thank you very much!
Regards,
AngyoungHi DM,
Thanks for your reply!
I've found a workaround,which is calling OpenScript's APIs ,such as this.getScriptPackage().getRepository() and this.getScriptPackage().getWorkspace(),etc to locate the .jar file.
And this workaround can still work even though the script is run on other machine.
Sorry to reply you so late!
Regards,
Angyoung -
How to create a table in the file using java code.?
HI,
I should export the data from the view objects to a word document. I have done that but I should
display the data in the form of a table.
Kindly come up with the necessary information on how to create a table in the file using java.
Thanks,
PhaniHi, Thank you for responding to my query.
The below are the details of my code.
DCBindingContainer dcBindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding StudentDetailsContent =
(DCIteratorBinding)dcBindings.get("StudentView1Iterator");
OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
Row currentRow =
StudentDetailsContent.getRowSetIterator().first();
Object a[]= currentRow.getAttributeValues();
int i;
for(i=0 ;i<=a.length;i++){
w.write(a.toString());
w.write(" ");
w.flush();
I am usning this coding to achieve the task of exporting data to file.
I need to display this information in the table that is where I need help from you people.
Thanks, -
Updating an existing xml file using java code
hi friends,
I have simple problem, I have an existing xml file and I want to update some of the values in the file.
can any one send me the java code for that.
bye.
-harishorg.w3c.dom.Document d = parseXmlFile("D:/www/Detailcache/detail.xml", false);
public static Document parseXmlFile(String filename, boolean validating) {
try {
// Create a builder factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(validating);
// Create the builder and parse the file
Document doc = factory.newDocumentBuilder().parse(new File(filename));
return doc;
} catch (Exception e) {
System.out.println("ERROR-->");e.printStackTrace();
return null;
look at .. for more related examples
http://javaalmanac.com/egs/javax.xml.parsers/BasicDom.html?l=rel
Maybe you are looking for
-
Help needed! Just want to cancel my year subscription. No answer from support via mail, noone answers when I call, support chat don't work.
-
Problem in displaying image when running a jad file
I have written a midlet which displays an image in the welcome screen and then shows the main menu for the application. WHen I try to run the code directly from the console by using the command "midp -classpath . teledoc", the code runs fine and also
-
HP ProBook 4530s mouse touch pad
I have disabled mouse touch pad. Having restarted laptop I noticed that LED indicator for mouse touch pad was turned off and mouse pointer accepts finger moves/clicks on touch pad (it was enabled) until I logged on when LED turned on and mouse touch
-
I attached an lov to text item in oracle form. if i write some thing in text item and it is first also have been written then show me it like when we write email in yahoo if those email is already been written then in below it shown like popup or too
-
No progress indicator or report for Tools menu sequence execution?
I have a sequence that I call from the TestStand customized Tools menu. This sequence generates custom reports on sequences. The report generation process can take anywhere from 10 to 60 seconds (there are DB queries involved). I hoped to use the Tes