File Input

Maybe someone can clarify,
I am looking for examples where a program allows me to input data from a file,
http://chortle.ccsu.edu/CS151/Notes/chap22/ch22_8.html
on the above webpage there is a good explanation, but it's still not clear when I am writing a program how to fit this together. Should I write a program to create the file first? And what if I want to send the output to another file?
import java.io.*;
class AddTwo
  public static void main ( String[] args ) throws IOException
    int numberA, numberB;
    String line;
    BufferedReader stdin = new BufferedReader(
        new InputStreamReader( System.in ) );
    System.out.println("Enter first number:");
    line      = stdin.readLine();
    numberA   = Integer.parseInt( line );
    System.out.println("Enter second number:");
    line      = stdin.readLine();
    numberB   = Integer.parseInt( line );
    System.out.println( "Sum: " + (numberA + numberB) );
}

My question is how to fit these together into a program that does what I want it to,
it's not clear to me how to produce a program that inputs the data from the file.
On the next page the text gives the following, but it does not explain how to:
create a program with the input.txt file or another type of file
how to read Line 1 A * B, Line 2 A + B
how to output the data
with a GUI or without
how to output the data to another file?
I want to enter A * B, C *D, and then calculate totals.
with a file, rather than entering all the data by hand.
The next page shows the following:
Here is an input file for use with this program. The file is named input.txt.
12
7
Here is a sample run of the program with this data file:
C:\users\default\JavaLessons>java AddTwo < input.txt
Enter first number:
Enter second number:
Sum: 19
C:\users\default\JavaLessons>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • Getting parameters from text and file input tag. .  canyou help me ?

    Hello!
    Is there anyway of getting parameters from an
    text field input in a form like :
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
    on the same form. It is something likethis :
    Form.jsp
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >   
    <input type="text" id="name" name="signinName" />
    <input name="signinFile" id="fileUp" type="file" />   
    <input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
    .//upload the file
    String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
    %>Thanks in advance for any suggestion!!
    All the best!

    You cannot use the HttpServletRequest object to retrieve parameters from a multipart form. You'll have to use a package that can parse such a form. I suggest Apache commons FileUpload.
    http://jakarta.apache.org/commons/fileupload/
    Using this package you can get both the file upload and any other parameters.

  • Passing request of file input type to a jsp

    Hi i m using this script for file uploading the form is.... <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="uploadscript.jsp" name="filesForm" enctype="multipart/form-data" method="post">
    Please specify a file, or a set of files:
    <input type="file" name="userfile_parent" value="userfile_parent" >
    <input type="submit" value="submit" value="Send">
    </form> </body> </html> And i am tring to get the url on uploadscript.jsp by using String parentPath=request.getParameter("userfile_parent"); but i foud that its value is NULL it is not working what should i do to get the userfile_parent on uploadscript.jsp help me!!! Message was edited by: UDAY Message was edited by: UDAY
    avajain      
    Posts: 135
    From: Noida , India
    Registered: 5/10/06
    Read      Re: Passing response but getting NULL
    Posted: Sep 20, 2006 2:43 AM in response to: UDAY in response to: UDAY      
         Click to reply to this thread      Reply
    Use method="GET" in place of method="post" .
    Thanks
    UDAY      
    Posts: 26
    From: JAIPUR
    Registered: 8/14/06
    Read      Re: Passing response but getting NULL
    Posted: Sep 20, 2006 3:18 AM in response to: avajain in response to: avajain      
    Click to edit this message...           Click to reply to this thread      Reply
    now it is giving this error message by e.getMessage()
    [br]the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
    the uploadscript is this....
    http://www.one.esmartstudent.com
    can u please help me.

    Here is sample code which we have used in one of our projects with org.apache.commons.fileupload.*.
    You can find String fullName = (String) formValues.get("FULLNAMES"); at the end that gives name of file.
    <%@ page import="java.util.*"%>
    <%@ page import="java.util.List"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.io.File"%>
    <%@ page import="java.io.*"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page import="org.apache.commons.fileupload.disk.*"%>
    <%@ page import="org.apache.commons.fileupload.servlet.*"%>
    <%!     
         //method to return file extension
         String getFileExt(String xPath){ 
                   //Find extension
                   int dotindex = 0;     //extension character position
                   dotindex = xPath.lastIndexOf('.');
                   if (dotindex == -1){     // no extension      
                        return "";
                   int slashindex = 0;     //seperator character position
                   slashindex = Math.max(xPath.lastIndexOf('/'),xPath.lastIndexOf('\\'));
                   if (slashindex == -1){     // no seperator characters in string 
                        return xPath.substring(dotindex);
                   if (dotindex < slashindex){     //check last "." character is not before last seperator 
                        return "";
                   return xPath.substring(dotindex);
    %>
    <%           
    Map formValues = new HashMap();
    String fileName = "";
    boolean uploaded = false;
         // Check that we have a file upload request
         boolean isMultipart = FileUpload.isMultipartContent(request);
         //Create variables for path, filename and extension
         String newFilePath = CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH");//application.getRealPath("/")+"temp";
         String newFileName ="";
         String FileExt = "";      
         //System.out.println(" newFilePath"+newFilePath+"/");
         //out.println(" newFilePath"+newFilePath+"<br>");
         // Create a factory for disk-based file items
         FileItemFactory factory = new DiskFileItemFactory();
         // Create a new file upload handler
         ServletFileUpload upload = new ServletFileUpload(factory);
         // Parse the request
         List /* FileItem */ items = upload.parseRequest(request);
         // System.out.println(" newFilePath"+newFilePath+"/");
         // Process the uploaded items
         Iterator iter = items.iterator();
         //Form fields
         while (iter.hasNext()) { 
         //System.out.println("in iterator");
              FileItem item = (FileItem) iter.next();
              if (item.isFormField()) { 
                   String name = item.getFieldName();
                   String value = item.getString();
                   if (name.equals("newFileName")) { 
                        newFileName = value;
                   //System.out.println("LOADING");
                   formValues.put(name,value);
              else { 
              //System.out.println("in iterator----");
                   String fieldName = item.getFieldName();
                   fileName = item.getName();
                   int index = fileName.lastIndexOf("\\");
              if(index != -1)
                        fileName = fileName.substring(index + 1);
              else
                        fileName = fileName;
                   FileExt = getFileExt(fileName);
                   String contentType = item.getContentType();
                   boolean isInMemory = item.isInMemory();
                   long sizeInBytes = item.getSize();
                   if (fileName.equals("") || sizeInBytes==0){ 
                        out.println("Not a valid file.<br>No upload attempted.<br><br>");
                   } else { 
                   // out.println("ACTUAL fileName= " newFilePath"\\"+fileName+ "<br>");
                        //File uploadedFile = new File(newFilePath+"\\", newFileName+FileExt);
                        File uploadedFile = new File(newFilePath+"/",fileName);
                        File oldFile = new File(CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH")+"/"+fileName);
                        File oldFileApproved = new File(CoeResourceBundle.getEmailProperties("APPROVED_FILE_LOCATION")+"/"+fileName);
                        try{ 
                             if (!oldFile.exists()&&!oldFileApproved.exists())
                                  item.write(uploadedFile);
                                  uploaded = true;
                             //out.println(fileName+" was successfully uploaded as "+ newFileName+FileExt +".<br><br>");
                        catch (java.lang.Exception e) { 
                             out.println("Errors prevented the file upload.<br>"+fileName+ " was not uploaded.<br><br>");
         String userid = (String) formValues.get("USERID");
         String fullName = (String) formValues.get("FULLNAMES");
         String email = (String) formValues.get("EMAILID");
         String empno = (String) formValues.get("EMPNO");
         String docType = (String) formValues.get("DOCTYPE");
         String desc = (String) formValues.get("MYTEXT");
         String title = (String) formValues.get("TITLEBOX");
         String module = (String) formValues.get("MODULE");
         String techfunctype = (String) formValues.get("TECHFUNCTYPE");
    %>

  • Java.sql.SQLException: File input/output error: File input/output error: re

    Hi,
    We are using JCAPS 512. We use oracle eway to connect to Oracle 10g database. But sometimes we are getting the following exception
    and suddenly all jcds stop processing. If we restart the server again job continue processing, otherwise server hangs and nothing get processed.
    Exception is as follows
    java.sql.SQLException: File input/output error: File input/output error: reading: java.io.EOFException in statement [SET TABLE EVENT_STORE INDEX '11183416 55935']
         at org.hsqldb.Trace.getError(Unknown Source)
         at org.hsqldb.Log.runScript(Unknown Source)
         at org.hsqldb.Log.open(Unknown Source)
         at org.hsqldb.Database$Logger.openLog(Unknown Source)
         at org.hsqldb.Database.open(Unknown Source)
         at org.hsqldb.Database.<init>(Unknown Source)
         at org.hsqldb.jdbcConnection.openStandalone(Unknown Source)
         at org.hsqldb.jdbcConnection.<init>(Unknown Source)
         at org.hsqldb.jdbcDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(DriverManager.java:525)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at com.stc.eventmanagement.impl.DBEventStore$EventStoreDB.addNewConnection(DBEventStore.java:359)
         at com.stc.eventmanagement.impl.DBEventStore$EventStoreDB.getConnection(DBEventStore.java:444)
         at com.stc.eventmanagement.impl.DBEventStore$EventStoreDB.executeParameterizedQuery(DBEventStore.java:777)
         at com.stc.eventmanagement.impl.DBEventStore$EventStoreDB.access$000(DBEventStore.java:250)
         at com.stc.eventmanagement.impl.DBEventStore.getEventIDsList(DBEventStore.java:133)
         at com.stc.eventmanagement.impl.DBEventStore.getEventIDsList(DBEventStore.java:115)
         at com.stc.eventmanagement.impl.EventForwarderMBean.cachePersistedEvents(EventForwarderMBean.java:728)
         at com.stc.eventmanagement.impl.EventForwarderMBean.setup(EventForwarderMBean.java:334)
         at com.stc.eventmanagement.impl.EventForwarderMBean.invoke(EventForwarderMBean.java:565)
         at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
         at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
         at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
         at com.stc.eventmanagement.impl.EventManagementService.setupEventForwarderMbean(EventManagementService.java:270)
         at com.stc.eventmanagement.impl.EventManagementService.registerMBean(EventManagementService.java:147)
         at com.stc.eventmanagement.impl.EventManagementService.startService(EventManagementService.java:96)
         at com.stc.eventmanagement.impl.EventManagementResourceAdapter.start(EventManagementResourceAdapter.java:75)
         at com.sun.enterprise.connectors.ActiveInboundResourceAdapter.<init>(ActiveInboundResourceAdapter.java:94)
         at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:74)
         at com.sun.enterprise.connectors.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:269)
         at com.sun.enterprise.connectors.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:372)
         at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:204)
         at com.sun.enterprise.server.ConnectorModuleLoader.load(ConnectorModuleLoader.java:87)
         at com.sun.enterprise.server.ConnectorModuleLoader.load(ConnectorModuleLoader.java:108)
         at com.sun.enterprise.server.AbstractManager.load(AbstractManager.java:216)
         at com.sun.enterprise.server.AbstractManager.load(AbstractManager.java:106)
         at com.sun.enterprise.server.ApplicationLifecycle.onStartup(ApplicationLifecycle.java:183)
         at com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:295)
         at com.sun.enterprise.server.PEMain.run(PEMain.java:238)
         at com.sun.enterprise.server.PEMain.main(PEMain.java:186)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
    |#]
    Please provide some suggestions to overcome this  error
    Regards
    Venkatesh.S

    Delete the EventStoreDb.data file (its somewhere in your logical host) and restart the logical host.

  • How to get file input stream from the client machine by JSF Fileupload API?

    Dear Friends,
    How to get the file input stream from the client machine by JSF HtmlFileupload or fileupload API. At present, if i execute the file upload code in the client machine, it is able to get the local path of the file and looking for the file in server machine. So i am getting FileNotFoundException.
    E.g., If a file is located at client machine at following location means "C:\Test\Test.txt",
    uploadClass.getFileuploadComponent().getFilename().toString() returns "C:\Test\Test.txt". But it is looking for that file in server and throwing FileNotFoundException.
    Please post your replies soon.
    Thanks,
    JP

    Depends on which version of JSF you're using. If JSF 1.2, I wouldn't even bother trying to hack this into JSF itself unless you can use something like Seam 2 or richfaces.
    http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_fileUpload.html
    http://docs.jboss.org/seam/2.2.1.CR3/reference/en-US/html/controls.html#d0e29259 (look for s:fileUpload)
    But if I were you, a simple non-jsf form with a servlet works best for taking file uploads.
    As for JSF 2.0, there are other ways of getting it done.
    http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html

  • Could not process file 'Input 110110b.txt': com.sap.aii.adapter.file.

    I have a FILE Adapter using FTP as a transport that is generating a very odd error.
    The FTP sender channel is giving the following error is set up to retreive all files (*) from a specific directory.  If you look at the error, it indicates an error processing the file 'Input 110110b.txt' as a file -- the only way this filename woudl be visible is if the adapater interrogated the directory, or the filename was hard-coded in the file mask.  But the error indicates it can't change to the directory.  The only way it would have come up with the file is if it had already CD'd t that directory.
    1/7/11 8:12:01 AM   Retry interval started. Length: 60.0 seconds
    1/7/11 8:12:01 AM   Could not process file 'Input 110110b.txt': com.sap.aii.adapter.file.ftp.FTPEx: 550 Failed to change directory.
    1/7/11 8:12:00 AM   Processing started
    My first thought was a simple permission issue, so I opened a connection to server with FileZilla (an FTP client) and was able to retrieve the file without a problem.  I was also able to drop a file in the directory.  There is no permissions problem.

    Hi
    Please check the below points before processing any file
    a) check the File placing by a Local Plant FTP owner is using the same authentification credentials It means both PI and source team needs to use same FTP User ID and login credentials otherwise if suppose if source team is placing with one User and PI cannot able to pick that file as this User cannot have permissions in this case also u will get 550 error
    b) I know what ur telling is u manualy palced one file and able retrive...but do one thing u can login with same PI FTP login server credentials and then place the file with different name also I suggest lets test the channel by simply keeping
    . not simply * if you keep simply * then u cna use in receiver chanel while using dynamic connfiguration.
    Else give *.txt and then activate the channel and also please check the CACHE as well
    Regards
    Amar Srinivas Eli

  • Can't get java to read my file input

    I have a program that ask at prompt what the name of your input file will be... something for example like input.txt can be typed and a scanner puts that text "input.txt" into a string called maybe inputs.
    The problem I am having is I can not get the scanner to then look at the string and open the file with the same name in the folder and read it.
    I not sure if im putting the name correct in the new File so to make it look at "input.txt" and I keep getting Class FileNotFoundException
    any ideas?
    my code is below
    File f = new File(inputs);
    Scanner scan = new Scanner( f );
    String name = "";
    while(scan.hasNextLine()) // as long as there is another line to be read
         String text = scan.nextLine(); // read the first line
         Scanner scan2 = new Scanner(text); // set up a second scanner to process the String we just read in
         if(scan2.hasNext())
              name = scan2.next();
         else
              continue; // go to the next line
         System.out.println(name);
    }

    Java is likely looking for your file in a location other than where the file is. Do you know where your current user.dir is? Create a small program that does nothing but this:
    class Fubar
      public static void main(String[] args)
        System.out.println(System.getProperty("user.dir"));
    }Edited by: Encephalopathic on Mar 23, 2009 7:10 PM

  • Re: File Input Streams FileNotFoundException

    Hi,
    I'm having problems with file input streams.
    The program is supposed to read from an external file but when I run it in Sun ONE Studio 4 (update 1), it gives me a FileNotFoundException (The system cannot find the file specified). The file, class.dat, is in the same folder as the .java and .class files.
    Anyway, so I run the program through MS-Prompt commands and there is no problem. It executes fine and gives the right output. Go figure.
    Can anyone shed some light on what is going on? Anyone else with the same problem? Is there something I need to configure in SunStudio? Please help...
    Thanks
    The code is taken directly from Sams Java in 21 days.
    // code
    import java.io.*;
    public class ReadBytes {
    public static void main(String[] arguments) {
    try {
    FileInputStream file = new
    FileInputStream("class.dat");
    boolean eof = false;
    int count = 0;
    while (!eof) {
    int input = file.read();
    System.out.print(input + " ");
    if (input == -1)
    eof = true;
    else
    count++;
    file.close();
    System.out.println("\nBytes read: " + count);
    } catch (IOException e) {
    System.out.println("Error -- " + e.toString());

    FileInputStream file = new FileInputStream("class.dat");Is this the line that is giving you the error message? Always, when trying to open a disk file, give the full path. This is because, FileNotFoundException is thrown only in cases when your file cannot be found by your program. But you say that the file exists.
    Try giving your full path for the file...like:
    FileInputStream file = new FileInputStream("C:/Program Files/class.dat");
    //Ofcourse your path will be different. This is just an example!So try giving the full path and let me know.
    Vijay :-)

  • File Input Adapter - Dynamic Mode

    Hi,
    I want to use dynamicFile and dynamicPath together for file input adapter but I am getting error when I write both of them in DynamicMode parameter. Is it possible somehow?
    Let me explain my scneario. A server is generating logs and I need to read them from ESP. The server writes logs in a file and when size of the file reaches 100MB, logs are started to be written a new log file. So, I need to read each newly coming data from a single log file and also get entries from a new file if previous log file reaches its maximum size.
    How can I handle this kind of request?
    Thanks and regards,
    Bulut

    Hi Alice,
    To be able to use wildcard in the File Parameter, I should choose dynamicPath in dynamicMode paramater. But when I choose dynamicPath, adaptor didn’t read newly written entries (incremental data) in log files.
    Vice versa, to able to get incremental data from a log file I should choose dynamicFile in dynamicMode. This time, I could not use wildcard (*) and I should specify a certain file in File Parameter.
    you can see my adapter codes below:
         1- DynamicFile
    CREATE INPUT WINDOW InputWindow1 SCHEMA (
           Column1 string ,
           Column2 string ) PRIMARY KEY ( Column1 ) ;
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input1 TYPE toolkit_file_csv_input TO InputWindow1 PROPERTIES csvExpectStreamNameOpcode = FALSE ,
           dir = 'E:/gg/t' ,
           file = 'new2.txt' ,
           dynamicMode = 'dynamicFile' ,
           removeAfterProcess = FALSE ,
           csvDelimiter = ',' ,
           csvDateFormat = '' ,
           csvTimestampFormat = '' ,
           csvHasHeader = FALSE ,
           pollingPeriod = 5 ,
    scanDepth = 0 ;
         2-  DynamicPath
    CREATE INPUT WINDOW InputWindow1 SCHEMA (
           Column1 string ,
           Column2 string ) PRIMARY KEY ( Column1 ) ;
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input1 TYPE toolkit_file_csv_input TO InputWindow1 PROPERTIES csvExpectStreamNameOpcode = FALSE ,
           dir = 'E:/gg/t' ,
           file = '*' ,
           dynamicMode = 'dynamicPath' ,
           removeAfterProcess = FALSE ,
           csvDelimiter = ',' ,
           csvDateFormat = '' ,
           csvTimestampFormat = '' ,
           csvHasHeader = FALSE ,
           pollingPeriod = 5 ,
    scanDepth = 0 ;
    My new2.txt file includes:
    A,A
    B,B
    C,C
    D,D,
    I could not find a way to handle this situation. Do you have any idea? How can I use both dynamicFile and dynamicPath options together?
    Regards,
    Bulut

  • Form validation for file inputs

    Hi,
    Does anybody know if Spry can do a file input validation? I'm
    interested at least to check if the file is empty or not.
    Thanks

    is this a JavaScript question or a Java queston ?

  • Firefox is not sending file inputs through iframe

    i know this ain't a programming forum, but i'm having problems with firefox while trying to send file inputs through iframes.
    this is my code
    <pre><nowiki><form id="popup_form_archivo" method="post" action="'subir_imagen.php" target="wk_iframe" enctype="multipart/form-data">
    <input name="accion" value="subirImagen" type="hidden" />
    <input name="wkimg" type="file" id="popup_prompt_archivo" />
    </form>
    <iframe name="wk_iframe" id="wk_iframe" src="about:blank"></iframe></nowiki></pre>
    i send the form inputs to the iframe called wk_iframe, i get the data from the hidden input but not the file input..
    I dont know why is this happening?, because it used to work.
    Works good in safarin, Opera, Chrome, But not with Firefox
    I must say i love firefox and that's what i'm here..
    Please help me..

    I notice a single quote in action="'subir_imagen.php". Is that quote necessary?
    *https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
    *https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
    This should still be working as the docs indicate.
    Any errors showing in the Web Console (Firefox/Tools > Web Developer;Ctrl+Shift+K) or Browser Console?
    A good place to ask advice about web development is at the mozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the mozillaZine forum site in order to post at that forum.

  • Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    No, but PL/SQL can. Look at utl_file.
    John Alexander www.summitsoftwaredesign.com

  • Parameters used for file input

    Hi,
    PARAMETERS : P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY
    PARAMETERS : P_FNAME LIKE IBIPPARMS-PATH OBLIGATORY
    PARAMETERS : P_HFILE LIKE FILENAME-FILEINTERN OBLIGATORY
    PARAMETERS : P_NAME TYPE APQI-GROUPID.
    The above are the various ways of decalring the parameters for file input... can u tell me what is the difference between them & the situations or condition when, which one has to be used ??
    Regards,
    - Hello SAP

    Hi,
    I am assuming you are using the parameters to upload/download a file.
    Here is what they will do for you. Let us see the following file name parameter.
    <i>PARAMETERS : P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY</i>
    Defining the parameter this way will help you in using the obsolete function modules of WS_DOWNLOAD, WS_UPLOAD as their interface requires the filename to be defined this way. But the new replacement for them GUI_DOWNLOAD and GUI_DOWNLOAD defined the filename as a string. Also F4 function modules used for browsing through desktop directories for a file like KD_GET_FILENAME_ON_F4 also use the parameter of this type.
    So, if you are using a function module like the ones above, then you are better of with this parameter.
    Let us see this definition.
    <i>PARAMETERS : P_FNAME LIKE IBIPPARMS-PATH OBLIGATORY</i>
    This is no different from the one above, so it makes no difference.
    Next.
    <i>PARAMETERS : P_HFILE LIKE FILENAME-FILEINTERN OBLIGATORY</i>
    This is typically used for a logical file name, not a physical filename and path. What a logical filename does is that it allows you to define logically define filenames and use them in your programs at the same time giving you(or your network team) the flexibility to change the directory structure. When they change the directory structure, all you have to do is to change your logical path definition, rather than changing every single program that uses the path. FILE is the tcode for this area. Length of this is just 60 and so it may not be sufficient for the filename and path. But if you are using it as a logical file name, then it is useful when using function modules like FILE_GET_NAME which will read in a logical file name and give you the string containing the physical path and file name.
    Now the last one.
    <i>PARAMETERS : P_NAME TYPE APQI-GROUPID.</i>
    This is not at relevant for files. This is used in batch input and this is the name of the batch input session. It is 12 characters long.
    Hope this helps, if not please let us know.
    Srinivas

  • File Input Area ---- Thumbnail

    Hi,
    I have file input area of a form that users use to upload
    pictures. I would like it to have an area beneath to show a
    thumbnail of the picture they've just selected.
    Does anyone know how I would accomplish this?
    Thanks!

    Try reading in a String rather than a Label from the ObjectsInputStream
    printAll() is printing the components - an InputStream is NOT a visible object it is a pipe through which you receive data into your application
    try something like
    bb= new FileInputStream("c:\\atest.txt");
    cc=new ObjectInputStream(bb);
    text.setText((String)cc.readObject());
    This is of course assuming that a String is the Object type that has been stored in your file
    It might be worth looking at a BufferedReader rather than an ObjectInputStream
    Hope this helps

  • File input question

    I'm new to java and I'm trying to write a program using file input/output.
    The user is asked for the names of an input file and an output file.
    My question is that in case I don't specify the path of the input file, where should it reside?
    thanks,

    My question is that in case I don't specify the path
    of the input file, where should it reside? In the present working directory. Which is not reliably known at runtime. If the input file will remain unchanged, you can put it into your JAR (if you create one) or somewhere else in your classpath, like the package root, and use getClass().getResourceAsStream("/thefile.ext") to load it. That will always work.

Maybe you are looking for

  • Return / Exchange Question...

    I recently bought a MBP and when I got it opened, there was a small nick in the aluminum below the keyboard. I went in to the apple store twice about it, and the second time they were very helpful and told me to call apple care. After a while on the

  • Java aplication not able to detect card reader sometimes

    Hi We have a Java application (jre1.6.0_05.) which runs as window service under "Local System". It tries to detect card reader after every one minute. Normally it is working fine. However on some machines (which can be Windows XP, 2003 Server etc) so

  • Missing ART

    I need someones help, I have look all over the internet, I have over 8500 song on my Itunes with a 80 gig ipod so i have enough room. My problem comes with the ART I have art for every single MP3. I'm very meticulous about that, in Itunes you can see

  • Block auto-approval for initiator of project

    We have a need to requirement to block auto-approval for initiator of project invoices if he or she is also an approver. Please can someone clarify if this can be done using functional setups or WF customization is required.

  • Sub:ck11n not picking the routing automatically

    Hi Guru,             Create cost estimation (ck11n) ,not picking the routing data automatically