Input to file

hey im a student working on an exersise and im wondering how to take keyboard input and write it to a file that can later be viewed. my "teacher" has not told us how to do this in class and its not in our textbook.
im a first semester student so my knowlege is limeted, the program will take info about an employee, name, id#. . . stuff like that and write it to a file that can later be viewed. i've pretty much got it all except the input from keyborad and write to file part. can someone give me a code example and maybe a brief explenation of what it does. im pretty sure im supposed to be using the scanner for input

The creators of your Java book (if you are using the same one I am... Java software solutions for AP* Computer Science by Lewis Loftus and Cocking) have created a file for Keyboard input. First you need to import it.
import cs1.Keyboard;
next you set up your main method and assign a variable to the information you need.
String Name; int SocialSecurityNumber;
the code you use to get the input from the user is something like this:
Name = Keyboard.readString();
SocialSecurityNumber = Keyboard.readInt();
there are others such as getDouble() getChar(); etc.
If you need to create multiple people, I would say make that into a new class. Then create new employees. Once you create the new class you can say like Bob.getSSN() (Or whatever you called it) to get the social security number. Do that with all of the employees then you are all set.
Of coarse this will only work during the durration of the program itself, if you are talking about holding the information for use after you close the program then I cannot help you there.

Similar Messages

  • Is there an easy way to run an Ajax function from input type=file to test the file name in DB?

    I've had the <input type="file">  ... <cffile ...> thing going for a few years now. 
    There is a database where the uploaded file names are stored once the files are uploaded to the server.  It sees things in terms of problems and stores uploaded file name accordingly with the ProbID prepended onto the file name; e.g., MyPicture.jpg would end up in the designated directory and databawe as P416_MyPicture.jpg.  This allows user to store pictures with the same name in different problems without a conflict.  There has been an issue with certain characters (e.g., spaces, +, #, etc.) causing problems when they are in file names so we have come up with a way using the <cffile ... rename> to replace these chars with _.  This means that MyPic+.jpg would end up being P416_MyPic_.jpg. 
         This is where the problem appears.  If someone were to upload MyPic+.jpg after someone else uploaded MyPic_.jpg in the same problem, then the + file would overwrite the _ file before the system knew they had a problem.  And there is now way to restore the original file without going to the system backup and doing so – which is a whole other story … especially, if the person doesn’t tell anyone.
         The logical solution would be to be able to test the new final file name (the name after making the substitutions mentioned above) against the existing files in the database before you went from the page where the <input type=file> control to the associated _action.cfm page where the <cffile> object is located.  Given that this seems to be the province of Ajax, this would seem like a natural use of the really interesting technology.  I have can determine the file name from the onChange action on the <input type=File> so that this would be the place for Ajax to come to the rescue by looking up the final file name and then letting the user know whether the resultant name is a unique within the database or not.  If so, I'll just enable the Add button which sets right next to the <input > control and let them upload it.  If not, I'll put up an error message telling them that this file already exists in the system.
         This would be the perfect solution.  It would let me do some Ajax stuff like I've wanted to do for the past year, but never have had the time to do because this is the project that won't go away.  This is, in fact, the last thing of any consequence that remains to do on this 2-1/2 year nightmare – be careful what you wish for.  If I can get this done this week, then maybe I can finally take a weekend off … maybe it will finally come to an end.
         Which finally leads to my question:  I'm looking for some tips on how to get this thing going since I can barely spell Ajax.  I've got a book and looked at some stuff online about CF and Ajax, but a good example or two or three would be worth a day's worth of poking around on the web and in my books.
         Thanks in advance for any suggestions, ideas, help, whatever.
    Len

    Adam,
         Thank you for your suggestion, but, after spending the night working with Ben Forta's CF8, vol 2, Chap 34, working with <cfajaxproxy>, I was able to do exactly what I wanted and it appears, after some testing, to work exactly as I had envisoned it should. 
         I am now calling a JavaScript function (testFileName) from the onChage event on the <input type="file"> or Browse button, which calls my proxy.cfc that contains the server side of the equation.  This funciton testFileName (I've run out of cleaver function/file names).  The query contained therein hits the database to see if the passed in parameters can pull up an existing file.  If they do, the particulars (file name, data attahced, etc.) are returned to the JavaScipt procedure that puts up the error notice.  The user can then chose to either overwrite the file or quit.  Quiting leaves the your on the Attachment PopUp where he/she started with nothing being uploaded. 
         Thanks again for your suggestion.  I appreciate your taking the time to do so.
    Len

  • Error in the input config file

    Continue message previous.
    I need deploy my application "notitia". Return message:
    Failed to deploy web application "notitiancm". Error in the input config file. Attribute Options is a single value attribute.

    Don't use EMwebsite. It's SLOW and buggy. I disabled mine.
    You can see a lot more error messages using dcmctl:
    bin/emctl stop
    dcm/bin/dcmctl shell
    deployapplication -a myapp -f myapp.ear -co home
    geterror
    You can also check dcm's and opmn's log files for errors.
    Your error message sounds familiar. If you have manually edited http.conf and added multiple entries of ProxyPass or SetEnvIf or who knows what else, you come across an iAS feature. This ias903 core for win2k file
    $ORACLE_HOME/dcm/config/plugins/apache/modDirectiveMS.xsd
    is no good.
    You have to change things like these to maxOccurs="unbounded":
    <element name="SetEnvIf" type="string" minOccurs="0"
    maxOccurs="unbounded"/>
    Then do a
    dcmctl updateconfig.
    You can find the problem description in Meta-link ohs forum. Apparently the problem will be fixed in 904 but I don't know why we all have to go thru this rite of passage in the mean time... A waste of time.
    Ken

  • Uploading a file using input type=file

    Hi,
    I'm not sure if I'm in the right place or not. If not can you please let me know where to find and answer for my question.
    I'm trying to upload a file in oracle self-service (online page) and I found that the input type=file will let me select the file so I place the input type inside my htp.formopen command.
    I used the following when opening the formopen
    htp.formOpen(my_link, 'post',null, 'multipart/form-data');
    then I created the <input type="file"> tag
    But when I send the link to my second page to see if the input type works I get the page not found error.
    I'm thinking that maybe is because my 2nd page doesnt have a parameter that will hold the file but right now I'm not sure how to declare the file variables.
    Do you have any idea what could be wrong?
    Thanks

    What does your form do when you submit it? Handling file uploads is a bit of a convoluted process. I'd recommend starting here for some guidance:
    http://docs.oracle.com/cd/B14099_19/web.1012/b14010/concept.htm#i1005985

  • PI 7.1 : Taking a input PDF file and mapping it to a hexBinary attribute

    Hello All,
    We have a requirement which involves taking in an input PDF file and mapping it to a message type with binary attribute and sending it to an R3 system.
    Can anyone please detail the steps or point us to the correct documents for setting up the scenario.
    The scenario is file to Proxy adapter. The part which we need assitance is pulling up the input pdf and mapping it to binary field.
    Thanks.
    Kiran

    Thanks Praveen,Mayank,Sarvesh and Andreas for your  valuable help with the issue.
    I was able to successfully pick up the binary PDF file from a file server , encode it using Base 64 and post it to R3.
    I used the following code snippet and added the mentioned jar files to create a new jar file which was used as java mapping in the operation mapping.
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.*;
    import com.sap.aii.utilxi.base64.api.*;
    import java.io.*;
    import java.util.*;
    public class Base64EncodingXIStandard implements StreamTransformation{
         String fileNameFromFileAdapterASMA;
         private Map param;
         public void setParameter (Map map)
              param = map;
              if (param == null)
                   param = new HashMap();
         public static void main(String args[])
              Base64EncodingXIStandard con = new Base64EncodingXIStandard();
              try
                   InputStream is = new FileInputStream(args[0]);
                   OutputStream os = new FileOutputStream(args[1]);
                   con.execute(is, os);
              catch (Exception e)
                   e.printStackTrace();
    public void execute(InputStream inputstream, OutputStream outputstream)
                   DynamicConfiguration conf = (DynamicConfiguration) param.get("DynamicConfiguration");
                   DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
                   fileNameFromFileAdapterASMA = conf.get(KEY_FILENAME);
                   if (fileNameFromFileAdapterASMA == null)
                        fileNameFromFileAdapterASMA = "ToBase64.txt";
              try
                   while ((len = inputstream.read(buffer)) > 0)
                        baos.write(buffer, 0, len);
                   str = Base64.encode(baos.toByteArray());     //buffer);
                   outputstream.write("<?xml version=\"1.0\" encoding=\"utf-8\"?><ROOT>".getBytes());
                   outputstream.write(("<FILENAME>" + fileNameFromFileAdapterASMA + "</FILENAME>").getBytes());
                   outputstream.write( ("<BASE64DATA>" + str + "</BASE64DATA></ROOT>" ).getBytes());
              catch(Exception e)
                   e.printStackTrace();
         byte[] buffer = new byte[1024*5000];
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         int len;
         String str = null;
    I had to do the following configuration settings
    1)  Create a Sender Comm Channel with Adapter Specific message attributes and Filename checkbox checked.
    2) Use the Java Mapping in the Operation mapping.
    The scenario is working smoothly with out any issues.
    Thanks.
    Kiran

  • From browse button of input type=file, can I show the content of a file

    Hi all,
    I am using, input type=file, where browse button appears. I am having a text area. My requirement is after I select the browse button, I need to show the content of the file in the text area. As of now I 've handled by having another button 'show', which should be pressed after browse done. But, How to handle it in the browse button itself, how will I get that action event from browse button. Plz help.
    Regards,
    Sam

    I think someone asked a very similar question here,
    http://forum.java.sun.com/thread.jsp?forum=45&thread=501889
    check the thread, it may help you.
    -S-

  • How to get the path of input type="file" tag

    -- im using <input type="file"> tag to get an input file from a local host, it returns only the filename but not the complete path of the filename,,,
    -- i need to know on how to get the compelete path /directory of the filename using <input type="file"> tag , or is there any other way to get an input file from a local host aside from <input type="file"> tag?
    thanks

    http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_file.asp?frame=true
    When a file is uploaded, the file name is also submitted. The path of the file is available only to the machine within the Local Machine security zone. The value property returns only the file name to machines outside the Local Machine security zone. See About URL Security Zones for more information on security zones.
    i need to know on how to get the compelete path /directory of the filename
    using <input type="file"> tag You can't. Its a security thing.
    is there any other way to get an input file from a local host aside from <input type="file"> tag?No. Not using just html.
    You could always go into activex components, but thats different again.
    Cheers,
    evnafets

  • How to get full path using HTP.PRINT(' "input type ="file") ....

    Hello everybody,
    I am working on uploading file from page to another one using HTP package, but whenever I submit the form, it only takes the filename without the full path.
    for example :
    if i sent 'c:\dir\a.txt' , the other page receives file parameter as 'a.txt'
    the code is here
    PROCEDURE upload(appno in varchar2,wsct in varchar2) AS
    l_real_name VARCHAR2(1000);
    BEGIN
    HTP.htmlopen;
    HTP.headopen;
    HTP.title('Test Upload');
    HTP.headclose;
    HTP.bodyopen;
    HTP.header(1, 'Test Upload');
    HTP.print('<form action="https://ssltrng.uaeu.ac.ae/trng/document_api.upload1" method="get">');
    HTP.print(' File to upload: <input type="file" name="file" >
    HTP.print(' <input type="submit" value="Upload">');
    HTP.print('</form>');
    HTP.bodyclose;
    HTP.htmlclose;
    END upload;
    the other page see it as
    file is 'Water lilies.jpg'
    Thanks
    Edited by: dtabed on Mar 30, 2011 1:02 AM

    Do not understand the problem.
    The code you've posted is a PL/SQL web enabled procedure that produces a dynamic HTML page. This page contains a form. And a full URL reference to the CGI that will process the form's data.
    This is unusual - as it seems to be that the form is submitted across domains and web servers.. You usually refer to a local CGI procedure to deal with a form - no need for a fully qualified URL that includes web server and domain name.
    If the CGI procedure that receives the form is also a PL/SQL web enabled procedure, that the uploaded file will be placed in the documents table (as defined in the DAD alias) by mod_plsql, prior to the web enabled procedure being called. The documents table will contain the Mime type, file name, file contents and other details.

  • HTML tag input type="file"

    hello!
    i used the html tag <input type="file" name="fp"> to have a browse File in my html Page and succesfully gets the file,path and directory when i used fp.value on my windows but when i Load the Html file in Linux
    i only get the filename (excluding the Path)
    can someone tell how to get through this any solution ?
    nid yur help badly!
    Gud day!
    p.s. i used a javascript to get the pf.value.

    Here is a solution:
    Post your question on a relevant forum. These forums are for Java. Java is not Javascript. Javascript is not Java.

  • Try get value in input type="file". Not is full path. It's bug?

    In html:
    <input type="file" id="path_image">
    In javascript:
    path_image = document.getElementById("path_image").value;
    Example:
    Select path: "/images/image.gif"
    This result:
    path_image = " image.gif"

    You cannot preset input values for input type="file" elements. It's prohibited by HTML specification. It's namely a security hole.
    Imagine that one developed a webpage with input type="file" pointing to c:/passwords.txt and added window.onload=form.submit(), what would happen if one opened such a webpage?
    That said, get rid of scriptlets and step over to taglibs/EL. This is 2009, not 1999.
    <input type="text" name="foo" value="${param.foo}" />

  • How to process large input CSV file with File adapter

    Hi,
    could someone recommend me the right BPEL way to process the large input CSV file (4MB or more with at least 5000 rows) with File Adapter?
    My idea is to receive data from file (poll the UX directory for new input file), transform it and then export to one output CSV file (input for other system).
    I developed my process that consists of:
    - File adapter partnerlink for read data
    - Receive activity with checked box to create instance
    - Transform activity
    - Invoke activity for writing to output CSV.
    I tried this with small input file and everything was OK, but now when I try to use the complete input file, the process doesn't start and automatically goes to OFF state in BPEL console.
    Could I use the MaxTransactionSize parameter as in DB adapter, should I batch the input file or other way could help me?
    Any hint from you? I've to solve this problem till this thursday.
    Thanks,
    Milan K.

    This is a known issue. Martin Kleinman has posted several issues on the forum here, with a similar scenario using ESB. This can only be solved by completely tuning the BPEL application itself, and throwing in big hardware.
    Also switching to the latest 10.1.3.3 version of the SOA Suite (assuming you didn't already) will show some improvements.
    HTH,
    Bas

  • Changing the "Browse..." button label in input type file

    Hi,
    I am facing a problem. I have got an HTML page. On this page, I have got a file selector(input type = file) in which I want to change the label of the "Browse..." button. Does anybody have an idea, how can it be done?
    Thanks,
    Mayank

    I dont think it is possible...
    zakir

  • Error in the input config file.....delploying an app on oc4j

    Hi,
    When I try to deploy an application on an oc4j instance of Oracle 9ias it gives me the following error.
    "An error occured while undeploying the application. Error in the input config file. Attribute Group is a single value attribute."
    I am deploying the application through the EM website.
    Any pointers to the solution?
    Thanks in advance
    Kapil

    Don't use EMwebsite. It's SLOW and buggy. I disabled mine.
    You can see a lot more error messages using dcmctl:
    bin/emctl stop
    dcm/bin/dcmctl shell
    deployapplication -a myapp -f myapp.ear -co home
    geterror
    You can also check dcm's and opmn's log files for errors.
    Your error message sounds familiar. If you have manually edited http.conf and added multiple entries of ProxyPass or SetEnvIf or who knows what else, you come across an iAS feature. This ias903 core for win2k file
    $ORACLE_HOME/dcm/config/plugins/apache/modDirectiveMS.xsd
    is no good.
    You have to change things like these to maxOccurs="unbounded":
    <element name="SetEnvIf" type="string" minOccurs="0"
    maxOccurs="unbounded"/>
    Then do a
    dcmctl updateconfig.
    You can find the problem description in Meta-link ohs forum. Apparently the problem will be fixed in 904 but I don't know why we all have to go thru this rite of passage in the mean time... A waste of time.
    Ken

  • How do you find an event in iMovie? I input a file today.  It has disappeared.

    Today, i input a new event form my Sony camcorder into the latest version of iMovie.  It is labeled 2014-1-11.  I then imput another event and labeed it 2014-1-10. The first file name disappeared.  After about 75% of the second file was inported, iMovie unexpectedly quit.  After I opened iMovie again, both file names had disappeared.  I started to input the file that quit for a second time.  I received an error message that the file name 2014-1-10 was already in use, however I cannot find either of the files.  How can I find the missing files?
    Thanks.
    P.S.  So far, I do not like this version of iMovie.  I was getting half decent at using iMovie11.  The new version has been difficult for me to use.  It is taking forever to insert photos.  I am very frustrated.  I have talked to a few people at the Apple store and not getting a warm feeling that the situation will improve.  Does anyone know when a new version if iMovie for Dummies, or any kind of a comprehensive book on the latest version of iMovie, will be available? 

    Much appreciated, James. However, I found this response confusing, because until I read your message, I had renamed files in the finder by clicking near the begining of the file name. Maybe other people use that method to, so they may have initially misunderstood your response. So I thought I would mention that renaming in the finder with "enter" isn't the only way, but it appears so with iMovie. Thanks!

  • Use of input  type="file"

    Hellow
    How can I use the HTML tag <input type="file" > in jsp/servlets ?
    how can I got the file and saving it?

    Take a look at this page: http://search.java.sun.com/search/java/?qt=jsp+upload&x=39&y=6 - it is a search page and you can use it to find whether or not anyone has asked the question you have before. Often you will find that the question you have asked has been asked before, sometimes as much as 29000 times. It is quicker than asking a question for the first time because you don't have to wait for replies. - they are already there. I also believe that if you don't know understand search engines you are unlikely to understand Java.
    To help with your search you may want to know that the "file" input type creates a Multipart request and that the term "com.oreilly.servlets" may well be relevant too.

  • [SOLED] Firefox input type = file selects the wrong file

    When I have use a webpage in firefox that has an upload feature, Firefox often selects the wrong file. I can reproduce this problem by simply creating a form with an input tag like this:
    <input type="file" />
    When I enter the file selection screen and open fileA the input box contains fileA, fileB or fileC. It seems kind of random to me. I use KDE 4.5 btw, if that matters.
    Last edited by Wilco (2010-08-07 08:24:35)

    It seems to be some kind of kde problem. When I delete ~/.kde4/share/config/* it works fine. I tried deleting the all files in share/config starting with a-m and it still didn't work. Then I deleted every file from n-z and it didn't work so it's probably a combination of files that give these problems. I don't feel like setting up KDE all over again so damn, it's back to Icewm, again...

Maybe you are looking for

  • I'm getting a message ablout files having a 2g limit. what can i do?

    I have a new 15" macbook pro. had been messing w/GB several hours then it stops recording and the message comes up.

  • "Send to SpeedGrade" doesn't... do... anything...

    Hello -  I have been trying to get my project out of Premiere and eventually into DaVinci for grading. An Adobe rep suggested going to SpeedGrade, then saving an XML from there (in order to preserve nested sequences and merged clips).  I have not bee

  • Update itunes match info on the ipad. How?

    This is on an iPad (iOS 7.1.2).  I use iTunes Match (25,000 song limit account) where all my contents are MP3's from my CD's, either matched, or uploaded.  My library is large (24900+ tracks). The contents of my iTunes Match library are not displayin

  • PCNS Inclusion Group question

    Hi, To ensure PCNS works correctly, I assume you have to be part of the Inclusion Group at the time of your password change? The scenario I am thinking of is where FIM manages the membership of the Inclusion Group...and the user changes their passwor

  • Have: The disk cannot be partitioned because some files cannot be moved.

    Hi, I have defragmented my hard drive with iDefrag and still am getting this error when trying to use Boot Camp assistant.  I have a 2007 iMac 24" Model 7,1.  I am running 10.6.8 and trying to create a Windows partition of approximately 100G of the 1