Problem in java.io.file reading

Hi
I have a servlet and it calls some classes which are kept in a jar file in WEB-INF/lib directory. With in one of the classes there is a IO file read happening. How should i read the file and what path should i put if the file is in WEB-INF/resources
my jar files are in web-inf/lib directory. How will i read the file and what should be the patch to be given
regards,
Sujesh

Hi Sujesh,
you can use getResource(path) or getResourceAsStream, see http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html
See http://www.slamb.org/projects/axamol/sql-library/manual/ch01s03.html for an example.
Hope it helps
Detlev

Similar Messages

  • Problem opening java code file

    I downloaded some code for a slide out menu and am unable to open the file after unzipping it. Yes, I am a beginner and know near to nothing about java.
    Here's the message that came up:
    Script: C:\Documents and Setting\etc...etc
    Documents\passion\ssm6_6\ssmitmes.js
    Line: 1
    Char:1
    Error: Syntax error
    Code: 800A03EA
    Source: Microsoft JScript compilation error
    So what's with that? I know it's my computer but I don't know where to go for answers so I thought here'd be a good start.
    Any hints are greatly appreciated, thanks ya'll!!

    There is some errror in The ssmitmes.js java script file. Just try to edit it and clear it.

  • Java.io.File and uppercase/lowercase

    Hello,
    I am running into a weird problem with java.io.File on a Windows system. My program needs to validate a path the user entered. Sometimes, the path will contain a directory name that should be uppercase, but which the user entered in lowercase instead, and the <File>.exists() returns true anyways. I know on Windows, on the command line, directory and file names are not case-sensitive, which is probably why it was done that way. But this is causing problems because once the path is (supposedly) validated, it is handed to a Unix program (case-sensitive), and if it's not really valid there, the user has no way of correcting it. Whereas if it were found as invalid in the Java program, I could pop up an error, and the user could correct it.
    The bottom line is, is there a way of telling a File object to return false if the path name is not EXACTLY identical, on Windows? Or would I have to check the path myself, without relying on File?
    Thanks in advance,
    J-S

    In this case, this is not acceptable, since the files or directories on disk can be in any case. I just need the entered case to be exactly the same as the files.
    In other terms, I need File.exists() to return false if the case does not match. I would think there is a way to do this, since internally, the function checks if the operating system is Windows or Unix before doing the comparison, and acts differently in each case...
    From http://java.sun.com/j2se/1.3/docs/api/java/io/File.html (see equals or compareTo method) :
    "On UNIX systems, alphabetic case is significant in comparing pathnames; on Win32 systems it is not."
    I would like to force the Unix way of doing.

  • Problem with Java and Zip Files

    Hello there everyone. I have a problem with trying to zip up directories with empty folders in them. They zip fine with my code, but according to winzip, the number of files in the archive is incorrect. It's supposed to have a total of 288 files in it, but when it's zipped up, it only says 284. I mention specifically the "empty directories" note because the zipping works fine without empty folders.
    Below is the code for the zip method:
    public static void zip(File[] list, File zipfile, File zipRoot)
         throws IOException {
          if (!zipfile.exists()) {
                   zipfile.createNewFile();
              else if (!zipfile.isFile()) {
                   throw new IOException("The zip file, " + zipfile.getAbsolutePath()
                             + " is not a file.");
              if (list.length == 0) {
                  LOG.error("The list of files to zip up is empty.");
              for (int i = 0; i < list.length; i++) {
                   if (!list.exists()) {
                        throw new IOException("The file or directory, " + list[i].getAbsolutePath()
                                  + " does not exist.");
              FileOutputStream fos = new FileOutputStream(zipfile);
              ZipOutputStream zos = new ZipOutputStream(fos);
              for (int i = 0; i < list.length; i++) {
                   if (LOG.isDebugEnabled())
                        LOG.debug(i + ": " + list[i].getName());
                   String entryName = getRelativeName(list[i], zipRoot);
                   if (list[i].isDirectory()){
                        if (list[i].listFiles().length == 0){
                             ZipEntry entry = new ZipEntry(entryName + "/");
                             zos.putNextEntry(entry);
                   else {
                        ZipEntry ze = new ZipEntry(entryName);
                        zos.putNextEntry(ze);
                        byte[] buffer = new byte[8096];
                        FileInputStream fis = new FileInputStream(list[i]);
                        int read = 0;
                        read = fis.read(buffer);
                        if (LOG.isDebugEnabled())
                        LOG.debug("\tFound " + read + " bytes.");
                        if (read == -1){
                             //empty file, but add it for preservation.
                             //zos.write(buffer,0,0);
                        while (read != -1) {
                             zos.write(buffer, 0, read);
                             read = fis.read(buffer);
                        fis.close();
                        zos.closeEntry();
              zos.close();
    The files look like they're there, but I need the system to be able to determine the number correctly. 
    Here's the interesting thing:  It zips the files, and then when I use the size() method for zip files in java, it says 284 files.  But when I unzip, it says 288 again.  It's like there's files missing when compressed, but when decompressed, they return.  Note that the files are actually there.  If I open the archive in a third party app such as Winzip AND Winrar AND IZarc, they all show 288 files.  Any idea what would make the number of files appear incorrectly in a zip file when zipped by java with the code above?  Thanks in advance.
    - Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I figured out the problem. When zipping files in windows using winzip, it doesn't explicitly count folders as a "file/folder" as a file in itself. It will create the folders for files to go in, but the folder itself will not be 'counted' when you query the info of the file itself. You have more control of the zip file in java, and can count the folder as a file or not.

  • Static lookup lists:read data from a Java *.properties file

    Hi
    i need to make static lookup lists i am using read data from a Java *.properties file
    i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
    but i need to use the default language for that i update the loadDataFromPropertiesFile()
    method to find the correct properties file
    String temp=Locale.getDefault().getLanguage();
    String propertyFile =
    getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
    the problem:
    For English(TEST_en.properties) it is good and working
    For Arabic(TEST_ar.properties) read from correct file _ar.properties
    but the dispaly character is wrong
    When Debug
    In the File 1=&#1583;&#1605;&#1588;&#1602;
    In debug 1=/u32423

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

  • Problem using a jar file : java.lang.ClassNotFoundException: ApiConn

    Hi everyone.
    i am running a form that use a bean_area to call a jar.
    but i am getting this error, thanks in advnce for any tip.
    Java Plug-in 1.6.0_33
    Using JRE version 1.6.0_33-b05 Java HotSpot(TM) Client VM
    User home directory = C:\Users\user1
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    java.lang.ClassNotFoundException: ApiConn
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at oracle.forms.handler.UICommon.instantiate(Unknown Source)
         at oracle.forms.handler.UICommon.onCreate(Unknown Source)
         at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)
         at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)
         at oracle.forms.engine.Runform.processMessage(Unknown Source)
         at oracle.forms.engine.Runform.processSet(Unknown Source)
         at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
         at oracle.forms.engine.Runform.onMessage(Unknown Source)
         at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
         at java.awt.EventQueue.access$000(Unknown Source)
         at java.awt.EventQueue$1.run(Unknown Source)
         at java.awt.EventQueue$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
         at java.awt.EventQueue$2.run(Unknown Source)
         at java.awt.EventQueue$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$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)
    Dumping class loader cache...
    Live entry: key=http://192.168.10.100:7778/forms/java/,frmall.jar,siberia_jpg.jar,ApiConn.jar,Hasher.jar,ReadCommand.jar,WriteCommand.jar,libAPI.jar, refCount=1, threadGroup=sun.plugin2.applet.Applet2ThreadGroup[name=http://192.168.10.100:7778/forms/java/-threadGroup,maxpri=4]
    Done.
    in my form i have created a bean_area and used as implementation class :ApiConn
    in my formsweb.cfg i used this configuration: archive=frmall.jar,siberia_jpg.jar,ApiConn.jar,Hasher.jar,ReadCommand.jar,WriteCommand.jar,libAPI.jar
    in my forms/java i have placed my jar files listed in the frmall.jar
    i guess i am missing something but i dont know what it is.
    here is my ApiConn.java from wich i generate my jar file:
    package libAPI;
    * This contains connection. Everything should be here,
    * should operate with this class only
    import java.io.*;
    import java.net.*;
    import java.util.concurrent.LinkedBlockingQueue;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    * @author janisk
    public class ApiConn extends Thread {
    private Socket sock = null;
    private DataOutputStream out = null;
    private DataInputStream in = null;
    private String ipAddress;
    private int ipPort;
    private boolean connected = false;
    private String message = "Not connected";
    private ReadCommand readCommand = null;
    private WriteCommand writeCommand = null;
    private Thread listener = null;
    LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
    * Constructor of the connection class
    * @param ipAddress - IP address of the router you want to conenct to
    * @param ipPort - port used for connection, ROS default is 8728
    public ApiConn(String ipAddress, int ipPort) {
    this.ipAddress = ipAddress;
    this.ipPort = ipPort;
    this.setName("settings");
    * State of connection
    * @return - if connection is established to router it returns true.
    public boolean isConnected() {
    return connected;
    public void disconnect() throws IOException{
    listener.interrupt();
    sock.close();
    private void listen() {
    if (this.isConnected()) {
    if (readCommand == null) {
    readCommand = new ReadCommand(in, queue);
    listener = new Thread(readCommand);
    listener.setDaemon(true);
    listener.setName("listener");
    listener.start();
    * to get IP address of the connection. Reads data from socket created.
    * @return InetAddress
    public InetAddress getIpAddress() {
    return sock == null ? null : sock.getInetAddress();
    * returns ip address that socket is asociated with.
    * @return InetAddress
    public InetAddress getLocalIpAddress() {
    return sock == null ? null : sock.getLocalAddress();
    * Socket remote port number
    * @return
    public int getPort() {
    return sock == null ? null : sock.getPort();
    * return local prot used by socket
    * @return
    public int getLocalPort() {
    return sock == null ? null : sock.getLocalPort();
    * Returns status message set up bu class.
    * @return
    public String getMessage() {
    return message;
    * sets and exectues command (sends it to RouterOS host connected)
    * @param s - command will be sent to RouterOS for example "/ip/address/print\n=follow="
    * @return
    public String sendCommand(String s) {
    return writeCommand.setCommand(s).runCommand();
    * exeecutes already set command.
    * @return returns status of the command sent
    public String runCommand() {
    return writeCommand.runCommand();
    * Tries to fech data that is repllied to commands sent. It will wait till it can return something.
    * @return returns data sent by RouterOS
    * @throws java.lang.InterruptedException
    public String getData() throws InterruptedException {
    String s = (String) queue.take();
    return s;
    * returns command that is set at this moment. And will be exectued if runCommand is exectued.
    * @return
    public String getCommand() {
    return writeCommand.getCommand();
    * set up method that will log you in
    * @param name - username of the user on the router
    * @param password - password for the user
    * @return
    public String login(String name, char[] password) {
    this.sendCommand("/login");
    String s = "a";
    try {
    s = this.getData();
    } catch (InterruptedException ex) {
    Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
    return "failed read #1";
    if (!s.contains("!trap") && s.length() > 4) {
    String[] tmp = s.trim().split("\n");
    if (tmp.length > 1) {
    tmp = tmp[1].split("=ret=");
    s = "";
    String transition = tmp[tmp.length - 1];
    String chal = "";
    chal = Hasher.hexStrToStr("00") + new String(password) + Hasher.hexStrToStr(transition);
    chal = Hasher.hashMD5(chal);
    String m = "/login\n=name=" + name + "\n=response=00" + chal;
    s = this.sendCommand(m);
    try {
    s = this.getData();
    } catch (InterruptedException ex) {
    Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
    return "failed read #2";
    if (s.contains("!done")) {
    if (!s.contains("!trap")) {
    return "Login successful";
    return "Login failed";
    @Override
    public void run() {
    try {
    InetAddress ia = InetAddress.getByName(ipAddress);
    if (ia.isReachable(1000)) {
    sock = new Socket(ipAddress, ipPort);
    in = new DataInputStream(sock.getInputStream());
    out = new DataOutputStream(sock.getOutputStream());
    connected = true;
    readCommand = new ReadCommand(in, queue);
    writeCommand = new WriteCommand(out);
    this.listen();
    message = "Connected";
    } else {
    message = "Not reachable";
    } catch (UnknownHostException ex) {
    connected = false;
    message = ex.getMessage();
    ex.printStackTrace();
    } catch (IOException ex) {
    connected = false;
    message = ex.getMessage();
    ex.printStackTrace();
    }

    I need your help again, i think this is a minor thing.
    i have compiled the class file that i needed and i signed it too. but now it is giving me a new error and need your tip.
    here is the java console loyout and my java file ((i think here is the problem in java file, something must be missing)).
    thanks in advance for any help.
    Java Plug-in 10.17.2.02
    Using JRE version 1.7.0_17-b02 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Administrator
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    network: Connecting http://192.168.10.100:7778/forms/lservlet;jsessionid=c0a80a6430d6e191eded93774f2f8d1bed73056e66ef.e3mObhiMbxeKe34PahiKbx4Nbh90n6jAmljGr5XDqQLvpAe with proxy=DIRECT
    security: Validate the certificate chain using CertPath API
    security: The certificate hasnt been expired, no need to check timestamping info
    security: Cannot find jurisdiction list file
    security: The CRL support is disabled
    security: The OCSP support is disabled
    security: This OCSP End Entity validation is disabled
    security: Checking if certificate is in Deployment denied certificate store
    security: Checking if certificate is in Deployment permanent certificate store
    basic: updateValidationResultsForApplet update
    cache: Mark prevalidated: http://192.168.10.100:7778/forms/java/ApiConn.jar true tm=1363335797289 cert=1371107987000
    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    java.lang.InstantiationException: oracle.forms.siberia.ApiConn
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at oracle.forms.handler.UICommon.instantiate(Unknown Source)
         at oracle.forms.handler.UICommon.onCreate(Unknown Source)
         at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)
         at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)
         at oracle.forms.engine.Runform.processMessage(Unknown Source)
         at oracle.forms.engine.Runform.processSet(Unknown Source)
         at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
         at oracle.forms.engine.Runform.onMessage(Unknown Source)
         at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(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.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
         at java.awt.EventQueue$4.run(Unknown Source)
         at java.awt.EventQueue$4.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)
    network: Connecting http://192.168.10.100:7778/forms/lservlet;jsessionid=c0a80a6430d6e191eded93774f2f8d1bed73056e66ef.e3mObhiMbxeKe34PahiKbx4Nbh90n6jAmljGr5XDqQLvpAe with proxy=DIRECT
    Exception in thread "Forms-DialogThread2" java.lang.NullPointerException
         at oracle.forms.handler.JavaContainer.onDestroy(Unknown Source)
         at oracle.forms.engine.Runform.destroyHandlers(Unknown Source)
         at oracle.forms.handler.DialogThread.doAlert(Unknown Source)
         at oracle.forms.handler.DialogThread.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Dumping class loader cache...
    Live entry: key=http://192.168.10.100:7778/forms/java/,frmall.jar,siberia_jpg.jar,ApiConn.jar,ConcealTextField.jar, refCount=1, threadGroup=sun.plugin2.applet.Applet2ThreadGroup[name=http://192.168.10.100:7778/forms/java/-threadGroup,maxpri=4]
    Done.
    here is my java file
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package oracle.forms.siberia;
    * This contains connection. Everything should be here,
    * should operate with this class only
    import java.io.*;
    import java.net.*;
    import java.util.concurrent.LinkedBlockingQueue;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import oracle.forms.*;
    * @author janisk
    public class ApiConn extends Thread {
    private Socket sock = null;
    private DataOutputStream out = null;
    private DataInputStream in = null;
    private String ipAddress;
    private int ipPort;
    private boolean connected = false;
    private String message = "Not connected";
    private ReadCommand readCommand = null;
    private WriteCommand writeCommand = null;
    private Thread listener = null;
    LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
    * Constructor of the connection class
    * @param ipAddress - IP address of the router you want to conenct to
    * @param ipPort - port used for connection, ROS default is 8728
    public ApiConn(String ipAddress, int ipPort) {
    this.ipAddress = ipAddress;
    this.ipPort = ipPort;
    this.setName("settings");
    * State of connection
    * @return - if connection is established to router it returns true.
    public boolean isConnected() {
    return connected;
    public void disconnect() throws IOException{
    listener.interrupt();
    sock.close();
    private void listen() {
    if (this.isConnected()) {
    if (readCommand == null) {
    readCommand = new ReadCommand(in, queue);
    listener = new Thread(readCommand);
    listener.setDaemon(true);
    listener.setName("listener");
    listener.start();
    * to get IP address of the connection. Reads data from socket created.
    * @return InetAddress
    public InetAddress getIpAddress() {
    return sock == null ? null : sock.getInetAddress();
    * returns ip address that socket is asociated with.
    * @return InetAddress
    public InetAddress getLocalIpAddress() {
    return sock == null ? null : sock.getLocalAddress();
    * Socket remote port number
    * @return
    public int getPort() {
    return sock == null ? null : sock.getPort();
    * return local prot used by socket
    * @return
    public int getLocalPort() {
    return sock == null ? null : sock.getLocalPort();
    * Returns status message set up bu class.
    * @return
    public String getMessage() {
    return message;
    * sets and exectues command (sends it to RouterOS host connected)
    * @param s - command will be sent to RouterOS for example "/ip/address/print\n=follow="
    * @return
    public String sendCommand(String s) {
    return writeCommand.setCommand(s).runCommand();
    * exeecutes already set command.
    * @return returns status of the command sent
    public String runCommand() {
    return writeCommand.runCommand();
    * Tries to fech data that is repllied to commands sent. It will wait till it can return something.
    * @return returns data sent by RouterOS
    * @throws java.lang.InterruptedException
    public String getData() throws InterruptedException {
    String s = (String) queue.take();
    return s;
    * returns command that is set at this moment. And will be exectued if runCommand is exectued.
    * @return
    public String getCommand() {
    return writeCommand.getCommand();
    * set up method that will log you in
    * @param name - username of the user on the router
    * @param password - password for the user
    * @return
    public String login(String name, char[] password) {
    this.sendCommand("/login");
    String s = "a";
    try {
    s = this.getData();
    } catch (InterruptedException ex) {
    Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
    return "failed read #1";
    if (!s.contains("!trap") && s.length() > 4) {
    String[] tmp = s.trim().split("\n");
    if (tmp.length > 1) {
    tmp = tmp[1].split("=ret=");
    s = "";
    String transition = tmp[tmp.length - 1];
    String chal = "";
    chal = Hasher.hexStrToStr("00") + new String(password) + Hasher.hexStrToStr(transition);
    chal = Hasher.hashMD5(chal);
    String m = "/login\n=name=" + name + "\n=response=00" + chal;
    s = this.sendCommand(m);
    try {
    s = this.getData();
    } catch (InterruptedException ex) {
    Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
    return "failed read #2";
    if (s.contains("!done")) {
    if (!s.contains("!trap")) {
    return "Login successful";
    return "Login failed";
    @Override
    public void run() {
    try {
    InetAddress ia = InetAddress.getByName(ipAddress);
    if (ia.isReachable(1000)) {
    sock = new Socket(ipAddress, ipPort);
    in = new DataInputStream(sock.getInputStream());
    out = new DataOutputStream(sock.getOutputStream());
    connected = true;
    readCommand = new ReadCommand(in, queue);
    writeCommand = new WriteCommand(out);
    this.listen();
    message = "Connected";
    } else {
    message = "Not reachable";
    } catch (UnknownHostException ex) {
    connected = false;
    message = ex.getMessage();
    ex.printStackTrace();
    } catch (IOException ex) {
    connected = false;
    message = ex.getMessage();
    ex.printStackTrace();
    }

  • Synchronous File Read on Invoke Problem

    I am trying to invoke file adapter to read the file once(Synchronous File Read) as described in Bpeltechadapter guide.
    Read about Synchronous File Reading Capability here download.oracle.com/otndocs/products/bpel/bpeltechadp.pdf
    Also read this: Re: Help! Three questions about FileAdapater. .
    I get this process generation failed when i try to build it. The Empty_msg in inputvariable of invoke works but problem is with Charges_msg in output variable.
    I am sure its something to do with ns but not getting it to work.
    PL_FileInbound.WSDL code*********************
    <definitions
    name="PL_FileInbound"
    targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/PL_FileInbound/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/PL_FileInbound/"
    xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
    xmlns:imp1="http://TargetNamespace.com/FA_ReadFile"
    xmlns:hdr="http://xmlns.oracle.com/pcbpel/adapter/file/"
    >
    <import namespace="http://xmlns.oracle.com/pcbpel/adapter/file/" location="fileAdapterOutboundHeader.wsdl"/>
    <types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/PL_FileInbound/">
    <import namespace="http://TargetNamespace.com/FA_ReadFile" schemaLocation="PipeDelimitedNIX_Charges.xsd" />
    <element name="empty"><complexType/></element>
    </schema>
    </types>
    <message name="Chargesheet_msg">
    <part name="Chargesheet" element="impl:Chargesheet"/>
    </message>
    <message name="Empty_msg">
    <part name="Empty" element="tns:empty"/>
    </message>
    <portType name="SynchronousRead_ptt">
    <operation name="SynchronousRead">
    <input message="tns:Empty_msg"/>
    <output message="tns:Chargesheet_msg"/>
    </operation>
    </portType>
    <binding name="SynchronousRead_binding" type="tns:SynchronousRead_ptt">
    <jca:binding />
    <operation name="SynchronousRead">
    <jca:operation
    PhysicalDirectory="C:\Incoming"
    InteractionSpec="oracle.tip.adapter.file.outbound.FileReadInteractionSpec"
    FileName="abcl.txt"
    DeleteFile="false"
    OpaqueSchema="false">
    </jca:operation>
    <input>
    <jca:header message="hdr:OutboundHeader_msg" part="outboundHeader"/>
    </input>
    </operation>
    </binding>
    <service name="PL_FileInbound">
    <port name="SynchronousRead_pt" binding="tns:SynchronousRead_binding">
    <jca:address location="eis/FileAdapter" />
    </port>
    </service>
    <plt:partnerLinkType name="Read_plt" >
    <plt:role name="Read_role" >
    <plt:portType name="tns:SynchronousRead_ptt" />
    </plt:role>
    </plt:partnerLinkType>
    </definitions>
    BPEL Source ******************************************
    <!--
    // Oracle JDeveloper BPEL Designer
    // Created: Sat Apr 29 16:52:43 CDT 2006
    // Author: dpatel
    // Purpose: Synchronous BPEL Process
    -->
    <process name="SynchronousFileRead"
    targetNamespace="http://xmlns.oracle.com/SynchronousFileRead"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/PL_FileInbound/"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:client="http://xmlns.oracle.com/SynchronousFileRead"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <!-- ================================================================= -->
    <!-- PARTNERLINKS -->
    <!-- List of services participating in this BPEL process -->
    <!-- ================================================================= -->
    <partnerLinks>
    <!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:SynchronousFileRead"
    myRole="SynchronousFileReadProvider"/>
    <partnerLink myRole="Read_role" name="PL_FileInbound"
    partnerRole="Read_role" partnerLinkType="ns1:Read_plt"/>
    </partnerLinks>
    <!-- ================================================================= -->
    <!-- VARIABLES -->
    <!-- List of messages and XML documents used within this BPEL process -->
    <!-- ================================================================= -->
    <variables>
    <!-- Reference to the message passed as input during initiation -->
    <variable name="inputVariable"
    messageType="client:SynchronousFileReadRequestMessage"/>
    <!--
    Reference to the message that will be returned to the requester
    -->
    <variable name="outputVariable"
    messageType="client:SynchronousFileReadResponseMessage"/>
    <variable name="Invoke_1_SynchronousRead_InputVariable"
    messageType="ns1:Empty_msg"/>
    <variable name="Invoke_1_SynchronousRead_OutputVariable"
    messageType="ns1:Chargesheet_msg"/>
    </variables>
    <!-- ================================================================= -->
    <!-- ORCHESTRATION LOGIC -->
    <!-- Set of activities coordinating the flow of messages across the -->
    <!-- services integrated within this business process -->
    <!-- ================================================================= -->
    <sequence name="main">
    <!-- Receive input from requestor.
    Note: This maps to operation defined in SynchronousFileRead.wsdl
    -->
    <receive name="receiveInput" partnerLink="client"
    portType="client:SynchronousFileRead" operation="process"
    variable="inputVariable" createInstance="yes"/>
    <!-- Generate reply to synchronous request -->
    <invoke name="Invoke_1" partnerLink="PL_FileInbound"
    portType="ns1:SynchronousRead_ptt" operation="SynchronousRead"
    inputVariable="Invoke_1_SynchronousRead_InputVariable"
    outputVariable="Invoke_1_SynchronousRead_OutputVariable"/>
    <!--outputVariable="Invoke_1_SynchronousRead_OutputVariable"-->
    <reply name="replyOutput" partnerLink="client"
    portType="client:SynchronousFileRead" operation="process"
    variable="outputVariable"/>
    </sequence>
    </process>
    I would really appreciate your help here.

    I face the same issue and I have given all permissions to the folder for OS user.
    Because of this error my server is not starting up . Is there any way I can undeploy this composite to get my server running.
    I cant do this from EM because SOA server is failing to start up.
    I have tried removing it from $DOMAIN_HOME/deployed-composites but still when i try restarting the soa server the composite comes up there. Do we need to delete the entry some where else too. Kindly help.
    Thanks,
    Sri.

  • Problem With File Reading And Sorting

    I'm having problems with a particular task. Here is what I have to do:
    Write a program which reads 100 integers from a file. Store these integers
    in an array in the order in whcih they are read. Print them to the screen.
    Sort the integers in place using bubble sort. Print the sorted array to the
    screen. Now implement the sieve of Eratosthenes to place all prime numbers
    in an ArrayList. Print that list to the screen.
    Here is the code I have so far:
    import java.util.ArrayList;
    import java.io.*;
    public class Eratosthenes
        private ArrayList numbers;
        private String inputfile1 = "numbers.txt";
        public Eratosthenes()
            numbers = new ArrayList();
        public void readData()
            try {
                BufferedReader reader = new BufferedReader(new FileReader(inputfile1));
                for(int i = 1; i <= 100; i++) {
                    String temp = reader.readLine();
                    numbers.add();
            catch(Exception e)
    This is the file reading part I have done but it doesn't recognise the line numbers.add() . It brings up the error - 'Cannot resolve symbol - method add(). Thats the first problem I have, can anyone see any way to fix it and to achieve the task. Also can someone help with the structure of a bubble sort method and a sieve of Eratosthenes method as I have no clue whatsoever. Any help will be greatly appreciated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Ok, I've done that but I'm having another problem. When I'm printing an output to the screen, it prints 100 lines of integers and not 1 line of 100 integers. Can you see the problem in the code that is doing this?
    import java.util.ArrayList;
    import java.io.*;
    public class Eratosthenes
        private ArrayList numbers;
        private String inputfile1 = "numbers.txt";
        public Eratosthenes()
            numbers = new ArrayList();
        public void readData()
            try {
                BufferedReader reader = new BufferedReader(new FileReader(inputfile1));
                for(int i = 1; i <= 100; i++) {
                    String temp = reader.readLine();
                    numbers.add(temp);
                    System.out.println(numbers);
            catch(Exception e)
    }

  • Problem in finding java class file

    I am writting an application using servlets , JSP and a simple java classfile. The simple java class file is for connection pool and the name of connection pool class is DBConnectionManager . I am using JavaWebserver2.0 and I have placed this class file in .\JavaWebserver2.0\classes
    I am placing my servlets in .\JavaWebserver2.0\servlets folder. Since I am using wfm package so my servlets are placed in .\JavaWebserver2.0\servlets\wfm .
    The problem is with compiling the servlet placed in wfm folder . I get the following error:-
    TestServlet.java:11:cannot resolve symbol
    symbol: class DBConnectionManager
    location: class wfm.TestServlet
    However when I try to compile this class in servlets folder and remove the package statement from the source file, it compiles and works very fine. I am having lot of confusion as the class DBConnectionManager is in classpath but even then compiler gives error. The same class when placed in servlets folder and package statement is removed works very fine.
    Kindly help.

    Hi,
    Is the DBConnectionManager class declared public?
    Does the TestServlet import the package that contains the DBConnectionManager?
    This is all I can come up with, with the current information.
    Cheers,
    --Arnout                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • How to read non-java binary file?

    Hello Team,
    I have problem to read non-java binary file.
    Let me explain.... I have one binary file created in vc++ having fix structure. Structure of file is like String,int,int,int.
    Now I have to read this file in my java application. I am failed to identify length of String value of Structure in java.
    Can any body help me to solve this problem?
    Thanks in advance.
    - Pathik

    Thanks for guide me,
    I have try using 0x00. And its working.
    Now I have another problem:
    in file.ext , I have written one record having structure string,int and int.
    I have enter data as "HelloWorld", 100 and 111.
    To read first record from file file.ext, following code I am using:
    try
         FileInputStream fis = new FileInputStream("file.ext");
         DataInputStream in = new DataInputStream(fis);
         char ch;
         while((ch=(char)in.readByte()) != 0x00)
              System.out.print(ch+"");
    System.out.println();
         System.out.println("Integer 1 --> " + in.readInt());
         System.out.println("Integer 2 --> " + in.readInt());
         in.close();
         fis.close();
    catch(Exception ex)
         System.out.println(ex.toString());
    And I am getting following output:
    HelloWorld
    Integer 1 --> 0
    Integer 2 --> 0
    File file.ext is created in vc++
    I am not getting integer data. Plz guide me for this problem.
    Thanks in advance
    - Pathik

  • How to read the java class file to convert it in java.

    hello all,
    i m developing the java application which generated the java code from the java 'class file' .
    Can anybody please help me, Is any java support for reading the class file? or how to know the class file format?
    I know the application javad, jad, javap which is doing the same thing.
    thanks for reply,
    - Jayd

    do you mean decompiling? there are tons of java decompilers available out there, what exactly are you trying to do here?

  • Problem:  this mac is not reading an excell file after upgrading to yosemite.   My Mac is from 2009, it use to work perfectly but it wasn´t able to open some apps, thats why i upgrade it.   Now it once i donwload the zip it appears with an ".ods" ext

    Problem:  this mac is not reading an excell file after upgrading to yosemite.   My Mac is from 2009, it use to work perfectly but it wasn´t able to open some apps, thats why i upgrade it.   Now it once i donwload the zip it appears with an ".ods" extension
    i even already download a link
    http://www.microsoft.com/en-us/download/confirmation.aspx?id=44026
    which i read on another support page... but it doesnt allowed me to install it cause it says that i already have the disk of this program....
    Im afraid to erase it and not being able to get it back...
    What can i do!??
    Thanks in advance for this kind answer!!!

    fsolution wrote:
    Problem:  this mac is not reading an excell file after upgrading to yosemite...   Now it once i donwload the zip it appears with an ".ods" extension...
    If the "it" refers to a compressed (zipped) spreadsheet that you downloaded, the ".ods" extension is used by LibreOffice and probably OpenOffice (which are free versions of MS Office) for spreadsheets, which would suggest that wherever you're getting that "Excel" file from has switched to one of those programs. I've tried opening an .ods file from LibreOffice using MS Office 2013 for Windows and it does open though with a warning that some things have been changed. I don't know if Office for Mac can normally open .ods files. But if your need is to just open .ods files, take a look at LibreOffice.

  • My itunes cannot be update on my windows xp. so i delete my itunes and install new, but now i got new problems, it says "The file itune.library.itl cannot be read because it was created by newer version of itunes." so how can it be solved?

    my itunes cannot be update on my windows xp. so i delete my itunes and install new, but now i got new problems, it says "The file itune.library.itl cannot be read because it was created by newer version of itunes." so how can it be solved?

    Hello Bebyida,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    http://www.apple.com/itunes/download/
    Best of luck,
    Mario

  • I'm having problems opening my pdf files. I'm running windows XP and have adobe reader XI (11.0.06)

    I'm having problems opening my pdf files. I'm running wiondows Xp and have adobe reader XI(11.0.06) installed.

    What kind of problems? What happens when you try? Any error messages?

Maybe you are looking for

  • Dynamic Configuration of HTTP Destinations in SOAPReceiver

    Dear PI Developers I'll define a dynamic Configuration for my HTTP Destination in SOAPReceiver with XI3.0 Protocol. The solution for that is to use an Adapter Module to set the dynamic Configuration Value. Process: ... > SOAP Receiver > MyAdapterModu

  • Translation of CRM Surveys

    Hi, we created Surveys for our activities in CRM 4.0. This surveys were translated into different languages. Until here all works fine. After creating and activating a new version of the 'masterlanguage'-survey, the translated surveys appear complete

  • Is it possible to load fxg graphics at runtime

    Hi All, I have costumers that want to change and update icons that where constructed with AI and are FXG graphics. Is is possible to load FXG graphics at runtime? Lior

  • Portions of email is garbled

    This mostly happens with Safari, but here's an example of an email I received from a local radio station. For the most part it's clear enough, but this section is a prime example of how the text can go wacky. Kansas City Chiefs will be featured in th

  • Update Attributes in UME

    Hi Is it possible to update attributes e.g Language in UME via security.api ?. Thanks Damien