JNI Invocation: open file in Java, write file in CPP

Hello,
Warning: I am a dunce, bad CPP code ahead!
Using JNI invocation, I am trying to read a binary file in Java and write it in CPP.
Everything compiles and runs without error, but the input and output jpg files are of course different.
TIA to any help,
kirst
(begin ByteMe.java)
import java.io.*;
public class ByteMe
    // Returns the contents of the file in a byte array.
    public byte[] getBytesFromFile(String strInfo) throws IOException
        System.out.println("Testing:" + strInfo);
        File file = new File("1.jpg");
        InputStream is = new FileInputStream(file);
        // Get the size of the file
        long length = file.length();
        // Create the byte array to hold the data
        byte[] bytes = new byte[(int)length];
        // Read in the bytes
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length
               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        // Ensure all the bytes have been read in
        if (offset < bytes.length)
            throw new IOException("Could not completely read file "+file.getName());
        // Close the input stream and return bytes
        is.close();
        return bytes;
    public ByteMe()
          //System.out.println("in constructor");
}(end ByteMe.java)
(begin ByteMe.cpp)
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <windows.h>
// for file operations:
#include <fstream>
int main( int argc, char *argv[] )
     JNIEnv *env;
     JavaVM *jvm;
     JavaVMInitArgs vm_args;
     JavaVMOption options[5];
     jint res;
     jclass cls;
     jmethodID mid;
     jstring jstr;
     jobject obj_print;
     options[0].optionString = "-Xms4M";
     options[1].optionString = "-Xmx64M";
     options[2].optionString = "-Xss512K";
     options[3].optionString = "-Xoss400K";
     options[4].optionString = "-Djava.class.path=.";
     vm_args.version = JNI_VERSION_1_4;
     vm_args.options = options;
     vm_args.nOptions = 5;
     vm_args.ignoreUnrecognized = JNI_FALSE;
     // Create the Java VM
     res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
     if (res < 0)
          printf("Can't create Java VM");
          goto destroy;
     cls = env->FindClass("ByteMe");
     if (cls == 0)
          printf("Can't find ByteMe class");
          goto destroy;
     jmethodID id_construct = env->GetMethodID(cls,"<init>","()V");
     jstr = env->NewStringUTF(" from C++\n");
     obj_print = env->NewObject(cls,id_construct);
     // signature obtained using javap -s -p ByteMe
     mid = env->GetMethodID(cls, "getBytesFromFile", "(Ljava/lang/String;)[B");
     if (mid == 0)
          printf("Can't find ByteMe.getBytesFromFile\n");
          goto destroy;
     else
          jbyteArray jbuf = (jbyteArray) env->CallObjectMethod(obj_print,mid,jstr);
          jlong size = jsize(jbuf);
          printf("size is: %d\n", size); // size shown in output is
          std::ofstream out("data.jpg", std::ios::binary);
          out.write ((const char *)jbuf, 100000);     
     destroy:
         if (env->ExceptionOccurred())
            env->ExceptionDescribe();
    jvm->DestroyJavaVM();
}(end ByteMe.cpp)

Hello,
Me again. Well, not such a dunce after all. Here is code that works correctly, and compiles with no errors and no warnings.
Will much appreciate help with clean-up code.
TIA,
kirst
(begin ByteMe.java)
import java.io.*;
public class ByteMe
    public long getFilezize(String strInfo) throws IOException
          // demonstrates String parameter passed from CPP to Java:
          System.out.println("(getFilesize) Hello world" + strInfo);
          File file = new File("1.bmp");
          InputStream is = new FileInputStream(file);
          // Get the size of the file
          long length = file.length();
          is.close();
          return length;
    // Returns the contents of the file in a byte array.
    public byte[] getBytesFromFile(String strInfo) throws IOException
        System.out.println("(getBytesFromFile) Hello world" + strInfo);
        File file = new File("1.bmp");
        InputStream is = new FileInputStream(file);
        // Get the size of the file
        long length = file.length();
        System.out.println("length is: " + String.valueOf(length));
        // Create the byte array to hold the data
        byte[] bytes = new byte[(int)length];
        // Read in the bytes
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0)
            offset += numRead;
        // Ensure all the bytes have been read in
        if (offset < bytes.length)
            throw new IOException("Could not completely read file "+ file.getName());
        // Close the input stream and return bytes
        is.close();
        return bytes;
    public ByteMe()
          //System.out.println("in constructor");
}(end ByteMe.java)
(begin ByteMe.cpp)
          Signature obtained with command:
               "C:\Program Files\Java\jdk1.5.0_15\bin\javap.exe" -s -p ByteMe
               Compiled from "ByteMe.java"
               public class ByteMe extends java.lang.Object{
               public long getFilezize(java.lang.String)   throws java.io.IOException;
                 Signature: (Ljava/lang/String;)J
               public byte[] getBytesFromFile(java.lang.String)   throws java.io.IOException;
                 Signature: (Ljava/lang/String;)[B
               public ByteMe();
                 Signature: ()V
     Compiled VC++ 2005 Express, run on Vista
#include <stdlib.h>
#include <string.h>
#include <jni.h>
// file operations
#include <fstream>
int main( int argc, char *argv[] )
     JNIEnv *env;
     JavaVM *jvm;
     JavaVMInitArgs vm_args;
     JavaVMOption options[5];
     jint res;
     jclass cls;
     jmethodID mid;
     jmethodID sizeid;
     jstring jstr;
     jobject obj_print;
     jlong filesize;
     options[0].optionString = "-Xms4M";
     options[1].optionString = "-Xmx64M";
     options[2].optionString = "-Xss512K";
     options[3].optionString = "-Xoss400K";
     options[4].optionString = "-Djava.class.path=.";
     vm_args.version = JNI_VERSION_1_4;
     vm_args.options = options;
     vm_args.nOptions = 5;
     vm_args.ignoreUnrecognized = JNI_FALSE;
     // Create the Java VM
     res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
     if (res < 0)
          printf("Can't create Java VM");
          goto destroy;
     cls = env->FindClass("ByteMe");
     if (cls == 0)
          printf("Can't find ByteMe class");
          goto destroy;
     jmethodID id_construct = env->GetMethodID(cls,"<init>","()V");
     printf("%s\n",id_construct);
     jstr = env->NewStringUTF(" from C++!\n");
     if (jstr == 0)
          // Normally not useful
          printf("Out of memory (could not instantiate new string jstr)\n");
          goto destroy;
     obj_print = env->NewObject(cls,id_construct);
     //BEGIN BLOCK to get file size
     sizeid = env->GetMethodID(cls, "getFilezize", "(Ljava/lang/String;)J");
     if (sizeid == 0)
          printf("Can't find ByteMe.getFilezize\n");
          goto destroy;
     else
          printf("got here\n");
          filesize =(jlong) env->CallObjectMethod(obj_print,sizeid,jstr);
          printf("got filesize\n");
     // END BLOCK to get file size
     // BEGIN BLOCK to write file
     mid = env->GetMethodID(cls, "getBytesFromFile", "(Ljava/lang/String;)[B");
     if (mid == 0)
          printf("Can't find ByteMe.getBytesFromFile\n");
          goto destroy;
     else
          jbyteArray ret =(jbyteArray) env->CallObjectMethod(obj_print,mid,jstr);
          // Access the bytes:
          jbyte *retdata = env->GetByteArrayElements(ret, NULL);
          // write the file
          std::ofstream out("data.bmp", std::ios::binary);
          //out.write ((const char *)retdata, 921654);
          out.write ((const char *)retdata, (long)filesize);
     // END BLOCK to write file
     destroy:
         if (env->ExceptionOccurred())
            env->ExceptionDescribe();
    jvm->DestroyJavaVM();
}(end ByteMe.cpp)

Similar Messages

  • How to convert oracle form fmb file to java swing file using Jdeveloper

    how to convert oracle form fmb file to java swing file using Jdeveloper.Please explain with detailes steps if possible or please give a link where it is available
    thanks
    Message was edited by:
    user591884

    There is no automatic way to do this in JDeveloper. I know there are some Oracle Partners offering forms to java conversion, I don't know how much of their tools are automated and done with JDeveloper. With JDeveloper+ADF you basically rewriting the Forms application from scratch (and using ADF is helpful during this process).

  • Trying to write data to a text file using java.io.File

    I am trying to create a text file and write data to it by using java.io.File and . I am using JDeveloper 10.1.3.2.0. When I try run the program I get a java.lang.NullPointerException error. Here is the snippet of code that I believe is calling the class that's causing the problem:
    String fpath = "/test.html";
    FileOutputStream out = new FileOutputStream(fpath);
    PrintStream pout = new PrintStream(out);
    Do I need to add additional locations for source files or am I doing something wrong? Any suggestions would be appreciated.
    Thank you.

    Hi dhartle,
    May be that can help:
    * Class assuming handling logs and connections to the Oracle database
    * @author Fabre tristan
    * @version 1.0 03/12/07
    public class Log {
        private String fileName;
         * Constructor for the log
        public Log(String name) {
            fileName = name;
         * Write a new line into a log from the line passed as parameter and the system date
         * @param   line    The line to write into the log
        public void lineWriter(String line) {
            try {
                FileWriter f = new FileWriter(fileName, true);
                BufferedWriter bf = new BufferedWriter(f);
                Calendar c = Calendar.getInstance();
                Date now = c.getTime();
                String dateLog =
                    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
                                                   Locale.FRANCE).format(now);
                bf.write("[" + dateLog + "] :" + line);
                bf.newLine();
                bf.close();
            } catch (IOException e) {
                System.out.println(e.getMessage());
         * Write a new line into a log from the line passed as parameter,
         * an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, String info) {
            lineWriter(header + " > " + info);
         * Write a new long number as line into a log from the line 
         * passed as parameter, an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, Long info) {
            lineWriter(header + " > " + info);
         * Enable to create folders needed to correspond with the path proposed
         * @param   location    The path into which writing the log
         * @param   name        The name for the new log
         * @return  Log         Return a new log corresponding to the proposed location
        public static Log myLogCreation(String location, String name) {
            boolean exists = (new File(location)).exists();
            if (!exists) {
                (new File(location)).mkdirs();
            Log myLog = new Log(location + name);
            return myLog;
         * Enable to create the connection to the DB
         * @return  Connection  Return a new connection to the Oracle database
        public static Connection oracleConnectionCreation() throws Exception {
            // Register the Oracle JDBC driver
            DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
            //connecting to the DB
            Connection conn =
                DriverManager.getConnection("jdbc:oracle:thin:@myComputerIP:1521:myDB","user", "password");
            return conn;
         * This main is used for testing purposes
        public static void main(String[] args) {
            Log myLog =
                Log.myLogCreation("c:/Migration Logs/", "Test_LinksToMethod.log");
            String directory = "E:\\Blob\\Enalapril_LC-MS%MS_MS%MS_Solid Phase Extraction_Plasma_Enalaprilat_ERROR_BLOB_test";
            myLog.lineWriter(directory);
            System.out.println(directory);
    [pre]
    This class contained some other functions i've deleted, but i think it still works.
    That enables to create a log (.txt file) that you can fill line by line.
    Each line start by the current system date. This class was used in swing application, but could work in a web app.
    Regards,
    Tif                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java write file restrictions, 3110

    Help please, I can't find right path for my files.
    Can I write files from unsubscribed java application? I've set application's option to "always ask" and always answering "YES" during write attempt.
    Аll paths:
    C:/
    C:/Gallery/
    C:/Gallery/test/ (folder was created from PC Suite)
    C:/test/
    C:/Галерея/ (I've switched phone to russian language)
    C:/Галерея/test
    still restricted (java exception).
    Is there right path, accessible from java?
    PS: Application is http://www.substanceofcode.com/software/mobile-trail-explorer/

    Software development and developer-to-developer support discussion forums/boards on Forum Nokia:
    http://forum.nokia.com/

  • Error running batch files from java source file???

    Dear Friends,
    hi,
    this is with response to a doubt i had earlier ,
    i want to run batch files from the java source file ,i tried using this code (here batrun is the batch file name that contains commands to run other java files)
    try
    String [] command = {"c:\\vishal\\finalmain\\batrun"};
    Runtime.getRuntime().exec(command);
    catch(Exception e)
    but i got the following error.
    java.io.IOException: CreateProcess: gnagarrun error= 2
    plz. help me, i tried all combination w/o success,
    in anticipation(if possible give the code after testing)
    Vishal.

    hello there,
    i solved the prob. by using
    cmd /c start filename ,but i need to pass parameters ie
    cmd /c start java "c:/vishal/runfile a b" where a and b are the parameters. but it is not accepting this in Runtime.getRuntime.exec(),
    any solutions ?????????
    regards,
    Vishal

  • Files.copy java.nio.file.AccessDeniedException

    Hello everybody,
    I hope you are well, Me not.
    I use this method to unzip
    public void deziper(final Path zipFile, final Path destDir) throws IOException*
              // On crée un FileSystem associé à l'archive :
         try ( FileSystem zfs = FileSystems.newFileSystem(zipFile, null) ) {
         // On parcourt tous les éléments root :
         for (Path root : zfs.getRootDirectories()) {
         // Et on parcourt toutes leurs arborescences :
         Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
         private Path unzippedPath(Path path) {
    return Paths.get(destDir.toString(), path.toString()).normalize();
         @Override
         public FileVisitResult preVisitDirectory(Path dir,
         BasicFileAttributes attrs) throws IOException {
         // On crée chaque répertoire intermédiaire :
         Files.createDirectories(unzippedPath(dir));
         return FileVisitResult.CONTINUE;
         @Override
         public FileVisitResult visitFile(Path file,
         BasicFileAttributes attrs) throws IOException {
         // Et on copie chaque fichier :
         Files.copy(file, unzippedPath(file), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
         return FileVisitResult.CONTINUE;
    Replace all files work well, but when application try to replace Executable Jar File in same directory This error is thrown
    09oct.2012 13:52:12,484 - 0 [AWT-EventQueue-0] WARN barakahfx.ModuleUpdater - Exception
    java.nio.file.AccessDeniedException: G:\Program Files\Djindo\Imanis\Djindo.jar
         at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
         at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
         at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
         at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
         at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(Unknown Source)
         at java.nio.file.Files.deleteIfExists(Unknown Source)
         at java.nio.file.CopyMoveHelper.copyToForeignTarget(Unknown Source)
         at java.nio.file.Files.copy(Unknown Source)
         at lib.GererFichier$3.visitFile(GererFichier.java:167)
         at lib.GererFichier$3.visitFile(GererFichier.java:150)
         at java.nio.file.FileTreeWalker.walk(Unknown Source)
         at java.nio.file.FileTreeWalker.walk(Unknown Source)
         at java.nio.file.FileTreeWalker.walk(Unknown Source)
         at java.nio.file.Files.walkFileTree(Unknown Source)
         at java.nio.file.Files.walkFileTree(Unknown Source)
         at lib.GererFichier.deziper(GererFichier.java:150)
         at barakahfx.ModuleUpdater.demarrerUpdate(ModuleUpdater.java:98)
         at barakahfx.AppliCtrl.demarrer(AppliCtrl.java:92)
         at barakahfx.BarakahFx$1.actionPerformed(BarakahFx.java:56)
         at javax.swing.Timer.fireActionPerformed(Unknown Source)
         at javax.swing.Timer$DoPostEvent.run(Unknown Source)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
         at java.awt.EventQueue.access$200(Unknown Source)
         at java.awt.EventQueue$3.run(Unknown Source)
         at java.awt.EventQueue$3.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Thank you very match
    Edited by: 964115 on Oct 9, 2012 5:39 AM
    Edited by: 964115 on Oct 9, 2012 5:40 AM
    Edited by: 964115 on Oct 9, 2012 5:46 AM
    Edited by: 964115 on Oct 9, 2012 5:55 AM

    Looks like you are trying to move the jar file you are executing and Windows has placed a lock on it. As far as I am aware there is no simple way round this. Why do you think you need to do this?

  • How to create .exe files from Java class files?

    I'm new to Java and I just wonder if it is possible to make executable files out of Java class files. I've checked the Java online help and several search engines, but I still couldn't find anything about that. Is it possible to do so? If not, why not?
    Thanx a lot for any help.

    I don't remember if there is a program that converts the class file,
    but I do know that there are a few that either convert the class file,
    or the .java file. You might try searching for ".java to .exe" in the
    search engine and seeing what that pulls up.

  • OPEN DATA SET to write files in application server folder - some of the files are missing

    Hi,
    I'm using OPEN DATASET statement in batch job to write the files in application server. what i'm experiencing is when i schedule the batch job all the files are not writing into the folder.
    If i run the report again to write the missed files, the files are writing into the application server folder.
    after opening the dataset, i'm closing it. do we need to give any delay between creation of the files? or until the first write operation is done, 2nd one can't start ..how can we achieve this.
    Thanks for your help in advance.
    Thanks,
    Adi.

    Hello Bathineni,
    Are you using the sy-subrc check after the OPEN DATASET statement.
    If not use a sy-subrc check and transfer the contents to file only when the OPEN DATASET returns value sy-subrc = 0.
    if sy-subrc is 8 repeat the same loop say for 3 attempts until the OPEN DATASET becomes 0.
    DO 3 TIMES. <---- put any number of attempts as you need
    OPEN DATASET.
    IF sy-subrc = 0.
       TRANSFER contents to file.
       EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET.
    Regards,
    Thanga

  • Creating win 32 exe files from java class files

    Hi I am using windows 2000.
    I have developed a java swing gui application that has about 10 class files. I downloaded the microsoft sdk for java 4.0 for converting all my class files into a single .exe file. I used jexegen in this SDK to do this process. But when I double click the exe file, it just pops up and closes instantenously without showing my startup frame.
    Can anyone help ?

    There is no Microsoft solution for this until you get J#, change your program
    (J# is a little bit different that java but not much, it's closer to Java than C#)
    and then compile to Win32 .exe.
    For the refrence list of all Java to Native code compilers, check this page:
    http://www.geocities.com/marcoschmidt.geo/jcomp.html#native :
    Different from "normal" compilers (like javac or jikes), native compilers do not create bytecode files
    (.class) that are interpreted by a Java Virtual Machine but native executables (like .exe files on
    Windows). "How do I create an EXE from Java?" is a very frequently asked question in newsgroups
    like comp.lang.java.programmer, native compilers are the answer. Some native compilers are listed
    below, check them out.

  • How can i convert  Javscript file to Java class file...?

    Hi,
    Actually in my project, JavaScript code will be given in text box and now I have evaluate the code and i have to create a class file for it. Till evaluating the JavaScript is done by using Javax.script package... but i don't now how to create a class file for the evaluated JavaScript code..
    Can any one help me on this issue....

    As has been mentioned Adobe Reader cannot export PDF page content. Nor can it create PDF or manipulate PDF page content.
    What you can do is use one of Adobe's online subscription services. Two provide for PDF  to Word export.
    There's ExportPDF and PDF Pack.
    Be well...

  • Unable to create file using java.io.File

    I have attached my code
    public boolean validateZip(MultipartFile file, List<String> files) throws Exception {
              String fileName = file.getOriginalFilename();
              File tempFile = new File("C://workspace//tempData//" + fileName);
              LOG.info("Absolute path : " + tempFile.getAbsolutePath());
              ZipFile zipFile = new ZipFile(tempFile);
              LOG.info("No of enteries in the zip : " + zipFile.size());
              //loop through the list and check if the entry is in the zip file
         }The problem is, no exception is thrown in
    ' File tempFile = new File("C://workspace//tempData//" + fileName);
    but, a FileNotFoundException is thrown in
      ZipFile zipFile = new ZipFile(tempFile);Also, it specifies the Absolute Path, but when I check there, there is no file created.
    Any help is appreciated.
    TIA

    ok, when I debug my application for the following code :
    String dir = "C:\workspace";
    String fileName = file.getOriginalFilename();   // file is an instance of a multipart file
    File tempFile = new File(dir, fileName);
    ZipFile zipFile = new ZipFile(tempFile);it runs smooth, no issues, if I run my app, the following line throws a FileNotFoundException...
    ZipFile zipFile = new ZipFile(tempFile);

  • Nfs mount point does not allow file creations via java.io.File

    Folks,
    I have mounted an nfs drive to iFS on a Solaris server:
    mount -F nfs nfs://server:port/ifsfolder /unixfolder
    I can mkdir and touch files no problem. They appear in iFS as I'd expect. However if I write to the nfs mount via a JVM using java.io.File encounter the following problems:
    Only directories are created ? unless I include the user that started the JVM in the oinstall unix group with the oracle user because it's the oracle user that writes to iFS not the user that creating the files!
    I'm trying to create several files in a single directory via java.io.File BUT only the first file is created. I've tried putting waits in the code to see if it a timing issue but this doesn't appear to be. Writing via java.io.File to either a native directory of a native nfs mountpoint works OK. ie. Junit test against native file system works but not against an iFS mount point. Curiously the same unit tests running on PC with a windows driving mapping to iFS work OK !! so why not via a unix NFS mapping ?
    many thanks in advance.
    C

    Hi Diep,
    have done as requested via Oracle TAR #3308936.995. As it happens the problem is resolved. The resolution has been not to create the file via java.io.File.createNewFile(); before adding content via an outputStream. if the File creation is left until the content is added as shown below the problem is resolved.
    Another quick question is link creation via 'ln -fs' and 'ln -f' supported against and nfs mount point to iFS ? (at Operating System level, rather than adding a folder path relationship via the Java API).
    many thanks in advance.
    public void createFile(String p_absolutePath, InputStream p_inputStream) throws Exception
    File file = null;
    file = new File(p_absolutePath);
    // Oracle TAR Number: 3308936.995
    // Uncomment line below to cause failure java.io.IOException: Operation not supported on transport endpoint
    // at java.io.UnixFileSystem.createFileExclusively(Native Method)
    // at java.io.File.createNewFile(File.java:828)
    // at com.unisys.ors.filesystemdata.OracleTARTest.createFile(OracleTARTest.java:43)
    // at com.unisys.ors.filesystemdata.OracleTARTest.main(OracleTARTest.java:79)
    //file.createNewFile();
    FileOutputStream fos = new FileOutputStream(file);
    byte[] buffer = new byte[1024];
    int noOfBytesRead = 0;
    while ((noOfBytesRead = p_inputStream.read(buffer, 0, buffer.length)) != -1)
    fos.write(buffer, 0, noOfBytesRead);
    p_inputStream.close();
    fos.flush();
    fos.close();
    }

  • Re: Scanning problem. Receive error message: cannot write file. Code 10,242,7. Please help

    hi. my error message is very close to this except it says 10,243,7 cannot read file instead of write file. i tried all the fixes listed here in this forum as well as just about everything else everyone else on here has listed on the net and even called canon and tried all their fixes as well to no avail. any ideas?
    [open window, place pc at edge gently tip and OOPS! crash! ]
    is anyone else getting this error message and if so; how'd you get around it?
    fixes tried:
    uninstalling
    reinstalling
    [several times]
    deleting all folders canon
    ccleaner-both the sweep and registry options with backups of course.
    sfc /scannow
    chkdsk
    thanks,
    pf

    Hi, pf!
    So that the Community can help you better, we will need to know exactly which operating system is running on your computer. That, and any other details you'd like to give will help the Community better understand your issue!
    If this is a time-sensitive matter, our US-based technical support team is standing by, ready to help 24/7 via Email at http://bit.ly/EmailCanon or by phone at 1-800-OK-CANON (1-800-652-2666) weekdays between 10 AM and 10 PM ET (7 AM to 7 PM PT).
    Thanks and have a great day!

  • How to debug byteCode? Can cap file convert to java source file?

    Are there tools can debug byteCode?
    Are there tools can convert cap file to java source file?
    Are there tools can convert jca file to java soure file?

    I think it's little bit difficult to give you a correct answer. Frankly speaking, cap file debugging is possible if you have sufficient devices and knowledge to do that. Converting cap file to java source code is also possible only if the cap file has descriptor component in it. Names of variables, functions will not be completely restored because cap file doesn't have the names in it. But I am not sure that there is a publicly opened tool to do that. JCVM chapter 6 may show you the way even it's not the direct one.

  • Failed to delete a file in MS Vista using java.io.File.delete()

    while trying to delete a file using java.io.File.delete(), it returns true but the file lies intact.
    i'm sure there is no handle or stream open on the file..
    the same code is running fine in XP..
    if anyone can help me.. thanks

    thanks all..
    the problem is diagnosed further..
    MS Vista does not let a user program to delete any file from 'windows' or 'program files' directories..
    Even when the file is deleted manually thru explorer a confirmation is taken from the administrator.. even when he is logged in..
    i for now have opted to install and use my program in Vista outside 'program files' directory...
    more clarification welcome..

Maybe you are looking for