A utility like Unix 'file' in Java?

Does any one know of a utility like the standard Unix utility 'file' that is written in Java?
'file' does more than look at filename extensions. It maintains a list of rules for identifying many file types based on their contents.
Thanks,
bw

Hi,
This is in relation to your previous post about Marshalling.
Were you ever able to work this problem out?
I am currently trying to DeMarshal a XML input stream back to a SOAP object. But for some reason my Object Marshalling class does not seem to execute. I have been able to Marshal an object to a SOAP object but the reverse does not seem to work.
Could you please shed some light on this problem?
Thanks.
XML and JAXB are new to me (well, I guess JAXB's new to everyone) so please excuse the elementary nature of this question.
Is it possible to marshall an arbitrary Java object to XML without explicitly writing a DTD?
I'm interested in storing instance of Java objects as XML, rather than serializing them. Is this possible? Is it crazy? Are there restriction on the kinds of objects that can be marshalled?
Eg. could a class like
public class ClassX {   Image img;   URL u;   long l;   String s;    public void someMethod() {}}
be marshalled?
Thanks,
bw

Similar Messages

  • How to run script file ( unix script file like ksh or sh file) using Java

    How to run script file ( unix script file like ksh or sh file) using Java Program?.
    I am using the following code snippet to run the simple commands like top or ls ,etc....
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("top");
    Thanks In Adavance
    -Siva

    String [] { "ksh" , "-c" , "script", "arg 1", "arg 2", "arg 3"}

  • Problem on Creating Unix Termial in java like windows command prompt

    hi all,
    i created an unix terminal using java swing(to connect unix server and executing commands). here i redirect the console output to textarea. The problem is i can't read the input from the textarea. and another problem is how to disable the editable option in the textarea before to the command read line. The terminal is like a putty. Any One Please give a suggestion for this problem.

    sabre150 wrote:
    georgemc wrote:
    LinaGsp wrote:
    5)then I run this command "jar cvfm MyJar.jar manifest.mf .class"If this is exactly what you did, and not a typo, that's probably your problem. Do you have a file called .class?It is more likely that the forum markup is getting in the way.Of course it is! D'oh! I seem to have a blind spot to that, I never take it into consideration...
    OP, listen to these guys, ignore this blind old fool :-(

  • Unzipping files using java.util

    I am trying to unzip files using java.util.zip
    It works fine when I am trying to unzip a file that is already residing on the server.
    But I want to unzip the file that user will upload to the server .
    My code is uploading zip file to server but not able to unzip this zip file giving error
    java.util.zip.ZipException: error in opening zip file
    What could be the problem
    I am not getting exactly
    Can you give me any clue
    Thanks

    sounds like the uploading is the problem. Are you FTPing the file? If so check that it's being transferred in binary, not ascii.

  • Java API getting unix file ownership(name, group..etc)

    I am looking for any standard or 3rd-paty Java API that retrieves unix file ownership (name, group..etc)
    Thanks.

    I don't like your chances of finding a standard library to pull Unix group and user ownership. That would be violating the whole theory of Java being OS agnostic. I'm also unaware of any 3rd party library that does this.
    That said, you can definitely do this. One way I can think of is making a Runtime call:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    You could use this to do an ls -l on a file and parse the result.
    This would of course be violating standard practice in J2EE when any access direct to the file-system is regarded as being a pretty bad idea. It would also make remove the write-once run-anywhere aspect to your code, though that may not concern you too much.
    cheers,
    Trevor Nielsen
    londonmiddleware.org

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • Can't create log file with java.util.logging

    Hi,
    I have created a class to create a log file with java.util.logging
    This class works correctly as standalone (without jdev/weblogic)
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.*;
    public class LogDemo
         private static final Logger logger = Logger.getLogger( "Logging" );
         public static void main( String[] args ) throws IOException
             Date date = new Date();
             DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
             String dateStr = dateFormat.format(date);
             String logFileName = dateStr + "SEC" + ".log";
             Handler fh;          
             try
               fh = new FileHandler(logFileName);
               //fh.setFormatter(new XMLFormatter());
               fh.setFormatter(new SimpleFormatter());
               logger.addHandler(fh);
               logger.setLevel(Level.ALL);
               logger.log(Level.INFO, "Initialization log");
               // force a bug
               ((Object)null).toString();
             catch (IOException e)
                  logger.log( Level.WARNING, e.getMessage(), e );
             catch (Exception e)
                  logger.log( Level.WARNING, "Exception", e);
    }But when I use this class...
    import java.io.File;
    import java.io.IOException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.logging.FileHandler;
    import java.util.logging.Handler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.XMLFormatter;
    public class TraceUtils
      public static Logger logger = Logger.getLogger("log");
      public static void initLogger(String ApplicationName) {
        Date date = new Date();
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String dateStr = dateFormat.format(date);
        String logFileName = dateStr + ApplicationName + ".log";
        Handler fh;
        try
          fh = new FileHandler(logFileName);
          fh.setFormatter(new XMLFormatter());
          logger.addHandler(fh);
          logger.setLevel(Level.ALL);
          logger.log(Level.INFO, "Initialization log");
        catch (IOException e)
          System.out.println(e.getMessage());
    }and I call it in a backingBean, I have the message in console but the log file is not created.
    TraceUtils.initLogger("SEC");why?
    Thanks for your help.

    I have uncommented this line in logging.properties and it works.
    # To also add the FileHandler, use the following line instead.
    handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandlerBut I have another problem:
    jdev ignore the parameters of the FileHandler method .
    And it creates a general log file with anothers log files created each time I call the method logp.
    So I play with these parameters
    fh = new FileHandler(logFileName,true);
    fh = new FileHandler(logFileName,0,1,true);
    fh = new FileHandler(logFileName,10000000,1,true);without succes.
    I want only one log file, how to do that?

  • How to open/read file using Java in Unix?

    Hi Friends,
    Can you please help me out how to open/read file using java in unix os? I have create one text file in "/home/test.txt" in unix environment. How to open the same file & read using java code?
    - Hiren Modi

    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Extracting file from a TAR file with java.util.zip.* classes

    Is there a way to extract files from a .TAR file using the java.util.zip.* classes?
    I tried in some ways but I get the following error:
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.<init>(ZipFile.java127)
    at java.util.zip.ZipFile.<init>(ZipFile.java92)
    Thank you
    Giuseppe

    download the tar.jar from the above link and use the sample program below
    import com.ice.tar.*;
    import java.util.zip.GZIPInputStream;
    import java.io.*;
    public class untarFiles
         public static void main(String args[]){
              try{
              untar("c:/split/20040826172459.tar.gz",new File("c:/split/"));
              }catch(Exception e){
                   e.printStackTrace();
                   System.out.println(e.getMessage());
         private static void untar(String tarFileName, File dest)throws IOException{
              //assuming the file you pass in is not a dir
              dest.mkdir();     
              //create tar input stream from a .tar.gz file
              TarInputStream tin = new TarInputStream( new GZIPInputStream( new FileInputStream(new File(tarFileName))));
              //get the first entry in the archive
              TarEntry tarEntry = tin.getNextEntry();
              while (tarEntry != null){//create a file with the same name as the tarEntry  
                   File destPath = new File(
                   dest.toString() + File.separatorChar + tarEntry.getName());
                   if(tarEntry.isDirectory()){   
                        destPath.mkdir();
                   }else {          
                        FileOutputStream fout = new FileOutputStream(destPath);
                        tin.copyEntryContents(fout);
                        fout.close();
                   tarEntry = tin.getNextEntry();
              tin.close();
    }

  • Java script in HTMLDB to check if file exists in Unix file system

    How do I use javascript to check if file is exists in Unix file system. I would like to dispaly the columns only if file is exists.

    Hello,
    This is one of those features that the manuals do not cover.
    How to use and build AJAX features could be a whole book all by itself, and it's not really HTML DB specific feature even though we have built some hooks in application and javascript to make it easier.
    Take a look at this thread
    Netflix: Nice UI ideas
    and I've built some examples here
    http://htmldb.oracle.com/pls/otn/f?p=11933:11
    Or just search the forums for AJAX or XMLHTTP
    Carl

  • Best way to copy/move files in Java...

    I am trying to write or use Java to create directories on the filesystem, based on user information to a servlet. Using the File object and calling the mkdir() method, this works really well. I would like to add the functionality of then moving several files from an existing directory to this new one.
    I can certainly write some code that uses the Runtime.getRuntime().exec("cp a.html b.html")and issue a system command, but if there's a better way, I'd appreciate it.
    Thanks,
    Jay

    If you are implying that he use th renameTo() utility
    of the File class, then that will only work when the
    underlying system allows it - E.G., no renames across
    mount points, hard drives, partitions, etc. Copy the
    file yourself (with 7 or 8 lines of code) and avoid
    the whole thing.I would be willing to accept these restrictions, but I never would have guessed that the renameTo() method would copy the file. That doesn't seem to make sense.
    So you think I should just write code that issues a system command. I was hoping to avoid that because I dev and test on my Windows machine, then deploy to Unix. Is there nothing out there that handles file copies?

  • Error reading zip file in Java 6

    We have a bespoke installer program that fails, intermittently, in Java 6 on Windows. After installing some files, it then fails with a stack trace like this:
    java.util.zip.ZipException: error reading zip file
         at java.util.zip.ZipFile.read(Native Method)
         at java.util.zip.ZipFile.access$1200(ZipFile.java:29)
         at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:447)
         at java.util.zip.ZipFile$1.fill(ZipFile.java:230)
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
         at java.io.FilterInputStream.read(FilterInputStream.java:90)
         at com.XXXX.trent.installer.Installer.writeStreamToFile(Unknown Source)
         at com.XXXX.trent.installer.Installer.installFile(Unknown Source)
         at com.XXXX.trent.installer.PatchFileInstaller.installFile(Unknown Source)
         at com.XXXX.trent.installer.PatchFileInstaller.installFiles(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller$TpfAction.run(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller.runActions(Unknown Source)
         at com.XXXX.trent.installer.UpgradeInstaller.install(Unknown Source)
         at com.XXXX.trent.installer.TrentInstall$SoftwareInstallStage.install(Unknown Source)
         at com.XXXX.trent.installer.TrentInstall$UpgradeInstallWorker.install(Unknown Source)
         at com.XXXX.trent.installer.PatchInstall$InstallWorker.construct(Unknown Source)
         at com.XXXX.trent.utils.SwingWorker$2.run(Unknown Source)
         at java.lang.Thread.run(Thread.java:619)The same code works in Java 5 on the same environments that it now fails in Java 6 (1.6.0_16).
    Any ideas?
    Thanks.

    gimbal2 wrote:
    it is not weird, it is a bug in the application. Don't let the upgrade from Java 5 to Java 6 make you believe otherwise.It's a singularly bad exception message though. I would have thought that something from java.util might be a bit more explicit about what the problem is.
    Winston

  • Executing batch file from Java stored procedure hang

    Dears,
    I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
    public static String runFile(String drive)
    String result = "";
    String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
    try {
    File directory = new File(drive + ":");
    File file = File.createTempFile("bb1", ".bat", directory);
    file.deleteOnExit();
    FileWriter fw = new java.io.FileWriter(file);
    fw.write(content);
    fw.close();
    // The next line is the command causing the problem
    Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null)
    result += line;
    input.close();
    file.delete();
    result = result.substring( result.lastIndexOf( ' ' )).trim();
    } catch (Exception e) {
    e.printStackTrace();
    result = e.getClass().getName() + " : " + e.getMessage();
    return result;
    The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
    I gave the SYSTEM schema the required privilege to execute the code.
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '&lt;&lt;ALL FILES&gt;&gt;', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SYSTEM;
    I have used the following to load the class in Oracle 9ir2 DB:
    loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
    CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
    I have seen similar problems on other forums, but no solution posted
    [http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
    I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
    Can anyne help?

    Dear Peter,
    You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
    I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
    The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
    The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
    where content of bb1.bat as follows:
    echo off
    vol C: | find /i "Serial Number is"
    The above batch file just get the serial number of hard drive assigned when windows formatted HD.
    Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    Never returns
    Thanks for tracing teh issue to that details ;) hope you coul help.

  • Bug on native code of OJVM java.util.zip.CRC32.updateBytes(CRC32.java)

    I want to unzip OpenOffice 1.0 files inside the OJVM but it fails into the native method java.util.zip.CRC32.updateBytes(CRC32.java).
    The first execution of the code runs OK, but the second not.
    After a long wait it shutdown the connection and the oracle trace file shows an stack trace like this:
    *** 2003-04-18 11:31:31.926
    *** SESSION ID:(17.97) 2003-04-18 11:31:31.926
    java.lang.IllegalArgumentException
    at java.util.zip.CRC32.updateBytes(CRC32.java)
    at java.util.zip.CRC32.update(CRC32.java)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java)
    at oracle.xml.parser.v2.XMLByteReader.fillByteBuffer(XMLByteReader.java:354)
    at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:142)
    at oracle.xml.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:448)
    at oracle.xml.parser.v2.XMLReader.fillBuffer(XMLReader.java:2012)
    at oracle.xml.parser.v2.XMLReader.skipWhiteSpace(XMLReader.java:1800)
    at oracle.xml.parser.v2.NonValidatingParser.parseMisc(NonValidatingParser.java:305)
    at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:274)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:254)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:225)
    at com.prism.cms.frontend.EditPropertiesActions.processUpload(EditPropertiesActions.java:1901)
    Exception signal: 11 (SIGSEGV), code: 1 (Address not mapped to object), addr: 0x6d3a74a0, PC: [0x40263600, eomake_reference_to_eobjec
    t()+80]
    Registers:
    %eax: 0x54a54000 %ebx: 0x40429c20 %ecx: 0x54a546bf
    %edx: 0x6d3a7478 %edi: 0x402b27d0 %esi: 0x45c718ac
    %esp: 0xbfffbf20 %ebp: 0xbfffbf48 %eip: 0x40263600
    %efl: 0x00010206
    The code of the java method is:
    public static void processUpload(String id_page, String longname,
    String filename, String filetype,
    String s00)
    throws SQLException {
    Integer p_id = new Integer(id_page);
    String toSource;
    XMLDocument doc = null;
    DOMParser theParser = null;
    InputStream XSLStream = null;
    BufferedWriter out = null;
    #sql { select path||name||'.html' into :toSource from pages where id_page=:p_id };
    if ("Cancel".equalsIgnoreCase(s00)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("no-file".equals(filename) && "no-contenttpye".equals(filetype)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("xml".equalsIgnoreCase(filetype))
    #sql { call CMSj.moveFromUpload(:filename,:p_id) };
    else if ("sxw".equalsIgnoreCase(filetype)) {
    XSLProcessor processor = new XSLProcessor();
    XSLStylesheet theXSLStylesheet = null;
    BLOB locator = null;
    // open sxw file, it will be in zip format with a file named content.xml
    // then convert content.xml to document-v10.dtd with an stylesheet
    #sql { select blob_content into :locator from wpg_document where name = :filename for update };
    ZipInputStream zin = new ZipInputStream(locator.binaryStreamValue());
    ZipEntry entry;
    try {
    while((entry=zin.getNextEntry())!=null)
    if ("content.xml".equalsIgnoreCase(entry.getName())) {
    Integer newVersion;
    CLOB dstDoc;
    CMSDocURLStreamHandlerFactory.enableCMSDocURLs();
    try {
    URL inUrl = new URL("cms:/stylesheets/sxw2document-v10.xsl");
    XSLStream = inUrl.openStream();
    // Create the Stylesheet from the stream
    theXSLStylesheet = processor.newXSLStylesheet(XSLStream);
    // Stores the document processing it with the given stylesheet
    theParser = new DOMParser();
    theParser.setValidationMode(theParser.NONVALIDATING);
    theParser.setBaseURL(new URL("cms:/dtd/"));
    theParser.parse(zin);
    doc = theParser.getDocument();
    #sql { SELECT NVL(MAX(version),0)+1 INTO :newVersion FROM content
    WHERE cn_id_page = :p_id };
    #sql { INSERT INTO content( cn_id_page, version, owner, status, source_file,
    file_size, content, created, modified, created_by,
    modified_by)
    VALUES ( :p_id, :newVersion, sys_context('cms_context','user_id'),
    'Uploaded', :filename, 0 , EMPTY_CLOB(), SYSDATE, SYSDATE,
    sys_context('cms_context','user_id'),
    sys_context('cms_context','user_id')) };
    #sql { SELECT content INTO :dstDoc FROM content
    WHERE cn_id_page = :p_id AND version = :newVersion for update };
    #sql { call DBMS_LOB.trim(:inout dstDoc,0) };
    out = new BufferedWriter(dstDoc.getCharacterOutputStream(),dstDoc.getChunkSize());
    processor.processXSL(theXSLStylesheet, doc, new PrintWriter(out));
    #sql { delete from wpg_document where name=:filename };
    } catch (SAXParseException spe) {
    throw new SQLException("processUpload SAXParseException: "+xmlError(spe));
    } catch (SAXException se) {
    throw new SQLException("processUpload SAXException: "+se.getLocalizedMessage());
    } catch (XSLException xsle) {
    throw new SQLException("processUpload XSLException: "+xsle.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream.close();
    if (theParser!=null)
    theParser = null;
    if (out!=null) {
    out.flush();
    out.close();
    zin.close();
    } catch (IOException ioe) {
    throw new SQLException("processUpload IOException: "+ioe.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream = null;
    if (out!=null)
    out = null;
    if (zin!=null)
    zin = null;
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    Basically it takes the content from a BLOB column of the wpg_document table, unzip it using java.util.zip package, look for the file content.xml and parse it using Oracle XML toolkit.
    Using an open source utility which replace java.util.package (http://jazzlib.sourceforge.net/) it works perfect because is a pure java application.
    Best regards, Marcelo.
    PD: I am using Oracle 9.2.0.2 on Linux.

    The cause of errors was a dying Westen Digital drive, specially the 48G partition reserved only for $ORACLE_BASE (/dev/sdb3 mounted on /opt/oracle).
    A simple quick scan of unmounted partition (badblocks -v /dev/sdb3) reported more than thousand new bad blocks (compared to the last scan six months ago). Although I strongly believe, specially in the case of WDC drives, that the best utility to "repair" bad blocks is the one that opens a window and prints the message: "Go to the nearest shop and buy a new drive", I was very curious to prove my suspicion just on this drive. After zero-filling the partition with dd, then formatting it (mke2fs -cc) and mounting again, the 11g installation and database creation (on the same partition) successfully completed, performing fast and smoothly. To make sure it was not a casual event, I repeated the installation once again with full success. The database itself is working fine (by now). Well, the whole procedure took me more than four hours, but I'm pretty satisfied. I learned once again - stay away from Western Digital. As Oracle cannot rely on dying drive, my friend is going tomorrow to spend a 150+ euro on two 250G Seagate Barracudas and replace both WDC drives, even though the first drive seems to be healthy.
    In general there is no difference between loading correct data from good disk into bad memory and loading the incorrect data from dying disk into good memory. In both cases the pattern is damaged. For everyone who runs into the problem similar to this, and the cause cannot be easily determined, the rule of thumb must be:
    1. test memory and, if it shows any error, check sockets and test memory modules individually
    2. check disks for bad blocks regardless of the result of memory testing
    Therefore I consider your answer being generally correct.
    Regards
    NJ

  • What path to use to access network files from Java app running on Mac

    I have a Java app running on a Mac with OS X that I'm using to check for files that exists on Windows servers within our network.
    Using a path like /Volumes/<Share>/ works because I've already connected to the drive using Finder. If I try to use a fully qualify the path with "smb://<Server>/<Share>" then my app doesn't see anything. Is there any way that I can get Java to connect to a directory without first having mapped or made the connection via some external tool like Finder?
    Here's the code I'm testing with:
    package FileImports;
    import java.io.File;
    import java.util.Arrays;
    public class Dir {
    static int indentLevel = -1;
    static void listPath(File path) {
    File files[];
    indentLevel++;
    files = path.listFiles();
    if (!(files == null)){
    Arrays.sort(files);
    for (int i = 0, n = files.length; i < n; i++) {
    for (int indent = 0; indent < indentLevel; indent++) {
    System.out.print(" ");
    System.out.println(files.toString());
    if (files[i].isDirectory()) {
    listPath(files[i]);
    indentLevel--;
    } else System.out.println("Directory not accessible!");
    public static void main(String args[]) {
    // this path works where <share> = the directory where my files exist.
    listPath(new File("/Volumes/<share>"));
    // this path returns a null result in files
    // listPath(new File("smb://<Server>/<Share>/"));
    Thanks,
    Alex
    Edited by: agates on Sep 25, 2008 11:14 AM

    agates wrote:
    Thanks for the response. I'll have to dig a little deeper into JCIFS. It looks like it would work great windows to windows. I haven't been able to find in the documentation where it would work on OS X without having to mount the targeted file system first. Has anyone had success creating a connection to a windows file system from OS X with JCIFS?Since jCIFS is written in pure Java and implements the entire SMB/CIFS protocoll on it's own it doesn't require any support from the OS (apart from a normal JVM runnig). Thus it should work exactly the same in OS X and Windows (and Linux and Solaris and ...).

Maybe you are looking for