User specifies file to be read in

I'm working on a program to count the words, characters, etc in a text file. I've just about got it all working, but at the moment I've got it specified in the actual code which text file the program should perform the word count on, whereas I want to alter this so that ther user types in the name of the file to use.
At the moment, I have it like this:
class WordCounter
     public static InputStreamReader input = new InputStreamReader(System.in);
     public static BufferedReader keyboardInput = new BufferedReader(input);
     public static void main(String[] args) throws IOException
FileReader file = new FileReader("report.txt");
BufferedReader MyFile = new BufferedReader(file);
String Text = MyFile.readLine();
and then the program uses the "Text" string in performing its checks.
How do I alter it so it prompts the user to enter the filename?
Obviously
System.out.println("Please enter a filename:");
and then something to replace the fileReader code I currently have, but what exactly?
Any help much appreciated

Aha, it's working!
Replacing
FileReader file = new FileReader("report.txt");
with
System.out.println("Please enter a filename:");
FileReader file = new FileReader(keyboardInput.readLine());
produced the desired result.
Many thanks for that!!!

Similar Messages

  • Win 8.1 / Server 2012R2: Setting User specific File Associating through GPO

    I have some issues associating the default application for specific users for specific file extentions.
    I've used registry imports in the times before GPO Preferences and have been using GPO Preferences for Vista/7/2008/2008R2 environments.
    With Win 8.1/2012R2 (and in some extend Win8/2012) I have read I should use the "Default Associations Configuration File" GPO option together with DISM. So, I followed these steps:
    Export current settings using: DISM /online /export-defaultappassociations:C:\Windows\System32\CustomAppAssoc.xml
    I've updated the file and imported it back: DISM /online /import-defaultappassociations:C:\Windows\System32\CustomAppAssoc.xml (*)
    Seeing this didn't work yet, I've also setup the GPO and pointed it to my C:\Windows\System32\CustomAppAssoc.xml
    I've removed the profile of my test-account and logged in
    (*) (To my knowledge this these steps only update the OEMDefaultAssociations.xml-file)Unfortunatly the changes I made, that should have assigned .xml to Microsoft Excel did not work.
    My file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <DefaultAssociations>
    <Association Identifier=".xml" ProgId="Applications\EXCEL.EXE" ApplicationName="Excel (desktop)" />
    </DefaultAssociations>
    A few issues I have:
    This method does not allow seem to enforce a default app; only add it to the list of available/suggested apps.
    This method does not allow me to associate different apps for different users
    Any tips would be more than appriciated.
    Kind regards,
    Peter

    You can use the Deployment Image Servicing and Management (DISM) tool to change the default programs associated with a file name extension.
    1.Deploy your Windows image to a test computer.
    2 Log into Windows and use Control Panel to configure your default application associations.
    3.You can export the default application associations that you have configured to an XML file on a network share or USB drive. For example, at a command prompt type the following command:
    Dism /Online /Export-DefaultAppAssociations:\\Server\Share\AppAssoc.xml
    4.Use GP server to enable the following group policy to modify the default Associations on the client machine.
    Computer Configuration>Administrative Templates>Windows Components>File explorer>Set a default associations configuration file.
    Regarding how to export or Import Default Application Associations,please refer to the following article:
    http://technet.microsoft.com/en-us/library/hh825038.aspx

  • Need user-specific files

    The way I currently work is, I have a JSP file that builds a user (log-in) specific agenda for a calendar. It does so by accessing a database and putting together a set of javascript commands.
    This works great for keeping each users agenda seperate and unreachable by other users. But, on one page the agenda is used just once, on another its used twice, and on a third it is used twelve times. This means the agenda.jsp can be reun up to 12 times on a given page, with all the sql and database access to go along with it!
    What I would like to do is have the server print an agenda.js (javascript file) only after each time the database is updated. This is easy enough. I can even tag the .js file with the sessionID or user-name, so there isn't cross-talk between users. But those .js files are still accessable to other users if they really want to get at them.
    I tried moving the files to WEB-INF, which will prevent people from accessing them from their browser by putting in a URL to them, but since the .js file needs to be read via a URL in my calendar script, this prevents my own pages from seeing it as well.
    Is there some other way I can securely lock out users from being able to see these files, but still be able to access them from the server side?

    I am getting a thought I will try to test this weekend.
    Put the files in WEB-INF/agendas/agenda_${sessionScope.userName}.js
    Then make an agenda.jsp that does <c:import url="WEB-INF/agendas/fagenda_${sessionScope.userName}.js"/> and use the agenda.jsp for the URL needed...

  • Open specific file, read entire contents, close - no user interaction

    I just want to wire in the file name to
    Open/Create/Replace File.vi
    and to
    File/Directory Info.vi

    You should be able to wire in a constant file path to both the open/create/replace file.vi and the file/directory info.vi. I have attached a VI written in LabVIEW 6.0 that opens a specific file, reads the entire content, and closes the file with no user interaction. Take a look at this example.
    Attachments:
    open_specific_file.vi ‏29 KB

  • How can user attach file to interactive form, and be read by abap program?

    Hello,
    I created an abap interactive form, sent to the user, then user fills out the form fields, then it is uploaded back to sap, then my program reads this data and process it.
    It works.
    Now I want users to be able to attach any file they want, and the abap program to extract this file out of the PDF, to put it into SAP (or anywhere).
    I succeeded in attaching a file, I can "see" it via function module get_annotations, but I get the file in compressed form by Adobe (filter="FlateDecode").
    Do you know how to unzip the file, or is there another way to attach files in adobe reader/extract them via abap?
    I use acrobat reader 8.1.2
    Thx a lot!
    sandra
    Below is the xml obtained by GET_ANNOTATIONS. We see that there are other text annotations, and that the attached file has {length="98005"}, though real file (before "attach file" to the PDF, and also after "detach file") has length 111 995 bytes. It's why I deduced that there is a compression (I also tried to extract it as-is and open it with adobe but it doesn't work.
    <?xml version="1.0" encoding="UTF-8"?>
    <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
      <annots>
        <highlight rect="212.347,624.257996,252.979004,636.539978" creationdate="D:20080604100938+02'00'"
    name="2114308b-275d-4eca-8bfc-c8288ef4a77c" color="#FFFF00" flags="print"
    date="D:20080604100938+02'00'" title="mtresori" subject="Texte surligne "
    coords="215.432999,636.179016,249.893005,636.179016,215.432999,624.619019,249.893005,624.619019"
    page="0">
          <popup rect="595.276001,516.179016,775.276001,636.179016" flags="print,nozoom,norotate"
    open="no" page="0"/>
        </highlight>
        <fileattachment rect="15.345001,802.841003,29.345001,822.841003"
    creationdate="D:20080604101011+02'00'" name="f6e12648-c9b0-4cd1-b08b-82876c8300d7"
    color="#4055FF" flags="print,nozoom,norotate" date="D:20080604101019+02'00'" title="mtresori"
    subject="Piece jointe" file="SAP_WIDGETS2.pdf" mimetype="application/pdf"
    creation="D:20080603112937+02'00'" modification="D:20080603112937+02'00'" size="111995"
    checksum="9F846412B510089F7C6DBCC6527C6339" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>SAP_WIDGETS2.pdf</p>
            </body>
          </contents-richtext>
          <data MODE="raw" encoding="hex" length="98005" filter="FlateDecode">
    4889CC570B5414D719F651A38EC468D5C6A2980104E528BBF3B8F3B2626405242920020A0AA4AEBB
    C3B2BAECEAEEA2A018030A628C8FFA4A0F568F58426A1EF5118FB5266A8D9AA2B16A55044541C5
    A62656EBA315935AE8BDB3BBEC2C0BD9D5B39EB3671966FEFBFCE6BF
    ETC. (all hexa code is the attached file, but with compression by adobe)
          </data>
        </fileattachment>
        <text rect="96.187408,680.099976,116.186996,698.099976" creationdate="D:20080613144537+02'00'"
    name="73360fcf-f5e5-4d5b-9315-fe4c42924300" color="#FFFF00" flags="print,nozoom,norotate"
    date="D:20080613144617+02'00'" icon="Comment" title="srossi" subject="Note" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p dir="ltr">
                <span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;
    font-weight:normal;font-style:normal">
    ffffffffffffffffffffff
                </span>
              </p>
            </body>
          </contents-richtext>
          <popup rect="595.276001,578.099976,775.276001,698.099976" flags="print,nozoom,norotate"
    open="yes" page="0"/>
        </text>
        <text rect="100,82,120,100" creationdate="D:20080613144627+02'00'" state="Marked"
    name="d524b7d5-1a85-4b62-80b3-5875dd152c51"
    color="#FFFF00" flags="hidden,print,nozoom,norotate" date="D:20080613144627+02'00'"
    icon="Comment" title="srossi" subject="Note"
    inreplyto="73360fcf-f5e5-4d5b-9315-fe4c42924300" statemodel="Marked" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>Marked definie par srossi</p>
            </body>
          </contents-richtext>
          <popuprect="595.276001,-20,775.276001,100" flags="print,nozoom,norotate" open="no" page="0"/>
        </text>
        <text rect="100,82,120,100" creationdate="D:20080613144633+02'00'" state="Accepted"
    name="88af2cb6-7516-4f21-81e6-97edc7a85184"
    color="#FFFF00" flags="hidden,print,nozoom,norotate" date="D:20080613144633+02'00'" icon="Comment"
    title="srossi" subject="Note" inreplyto="d524b7d5-1a85-4b62-80b3-5875dd152c51" statemodel="Review"
    page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>Accepted definie par srossi</p>
            </body>
          </contents-richtext>
          <popup rect="595.276001,-20,775.276001,100" flags="print,nozoom,norotate" open="no" page="0"/>
        </text>
        <text rect="100,82,120,100" creationdate="D:20080613144642+02'00'" state="Marked"
    name="a8c6b485-c3f9-44e2-ad53-c61b2766d9d5" color="#FFFF00" flags="hidden,print,nozoom,norotate"
    date="D:20080613144642+02'00'" icon="Comment" title="srossi" subject="Note"
    inreplyto="f6e12648-c9b0-4cd1-b08b-82876c8300d7" statemodel="Marked" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>Marked definie par srossi</p>
            </body>
          </contents-richtext>
          <popup rect="595.276001,-20,775.276001,100" flags="print,nozoom,norotate" open="no" page="0"/>
        </text>
        <text rect="100,82,120,100" creationdate="D:20080613144647+02'00'" state="Accepted"
    name="0136b689-575c-46b8-a21a-86e3c8d73904" color="#FFFF00" flags="hidden,print,nozoom,norotate"
    date="D:20080613144647+02'00'" icon="Comment" title="srossi" subject="Note"
    inreplyto="a8c6b485-c3f9-44e2-ad53-c61b2766d9d5" statemodel="Review" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>Accepted definie par srossi</p>
            </body>
          </contents-richtext>
          <popup rect="595.276001,-20,775.276001,100" flags="print,nozoom,norotate" open="no" page="0"/>
        </text>
        <text rect="100,82,120,100" creationdate="D:20080613144657+02'00'" state="Accepted"
    name="a21fc3c5-cf6a-4c6f-bc1f-328a91050b4e" color="#FFFF00" flags="hidden,print,nozoom,norotate"
    date="D:20080613144657+02'00'" icon="Comment" title="srossi" subject="Note"
    inreplyto="2114308b-275d-4eca-8bfc-c8288ef4a77c" statemodel="Review" page="0">
          <contents-richtext>
            <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
    xfa:APIVersion="Acrobat:8.0.0" xfa:spec="2.0.2">
              <p>Accepted definie par srossi</p>
            </body>
          </contents-richtext>
          <popup rect="595.276001,-20,775.276001,100" flags="print,nozoom,norotate" open="no" page="0"/>
        </text>
      </annots>
      <f href="acTempF-00000028453-00000000089"/>
      <ids original="03473EFED11DB2110A00000000000000" modified="959796E85292D54DB7FA558CAAD4A346"/>
    </xfdf>

    Hello everybody,
    I am sure you have an answer to my question above. It was :
    how is it possible for a user to ATTACH files to a PDF interactive form, and then be able to READ them via a program ? (I guess the solution to read them via ABAP or JAVA is quite the same?)
    Thx a lot !
    sandra

  • Can we give UNIQUE ACCESS FOR THE SPECIFIC FILE IN THE LIBRARY in SP2013? How can we remove users from SHARED WITH link where files are shared with users?

    Hi,
    Any help on this?
    Thanks
    srabon

    Hi srabon,
    For giving unique access for a specific file in a library, you can go to the library, and select the file , and click FILES->Shared With->ADVANCED, under PERMISSION ribbon, click ‘Stop Inheriting Permissions’, then the file will have unique permissions.
    For removing the shared users for a file, firstly, like the above steps, select the file , and click FILES->Shared With->ADVANCED , make sure the file has unique access, then select the users that you want to remove, and click Remove User Persmissions
    under PERMISSIONS ribbon.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • How I can know if a user has the permission to read a file or not ?

    Hello,
    I have other question :
    How I can know if a user has the permission to read a file or not ?
    Smaine
    ThanK's

    I don't think common operating systems have an easy way to do that check.
    If you have a limited number of files, implement access control yourself, instead of using operating system permissions. E.g. write a configuration file that contains:
    # Syntax: "filename": "list of users who can access that file"
    somefile.txt: fred, alice, bob
    somedir/anotherfile.txt: bob, joe
    Read in the configuration file and check against it when a file is being requested.

  • I am unable to accept the end user licensing agreement for adobe reader on my mac.  How do I fix this.  I can not open any files.

    I am unable to open any pdf files because I have not accepted the end user licensing agreement for adobe reader.  I can not find the accept button.  I have a mac.

    What is your screen resolution?  Can you post a screenshot of what you see: https://forums.adobe.com/thread/1070933

  • ATTN Java Gurus: udf.policy - Unable to Grant Read,Write to Specific File

    NOTE: A correct answer to this question will receive the rarely used OTN 25pt <font color="silver" size="3" face="script">Platinum Star</font><font color="silver" size="4" face="script"> &#9733;</font> *
    Essbase 9.3.1
    Using a Java CDF that reads and writes to a file
    I'm trying to grant permission to a specific file in the file system by granting permission in the udf.policy file.
    When I uncomment the line permission java.security.AllPermission; the CDF works fine and interacts with the file correctly. This is just to prove that the CDF works, I need to tighten this up to a single file. I stop and start the app after each edit.(I've also tried bouncing the Essbase server too)
    When I use the following, I get an exception, shown below. Nothing of consequence is being written to the app or essbase logs
    grant {
      permission java.io.FilePermission "C:/test/essbase/CalcProfile.db", "write, read";
    };java.security.AccessControlException: access denied (java.io.FilePermission C:\esstest\Server\PlugIns\Essbase read)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         at java.security.AccessController.checkPermission(AccessController.java:546)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
         at com.hyperion.essbase.calculator.ESecurityManager.checkRead(ESecurityManager.java:80)
         at java.io.File.exists(File.java:731)
         at org.sqlite.Conn.open(Conn.java:98)
         at org.sqlite.Conn.<init>(Conn.java:57)
         at org.sqlite.JDBC.createConnection(JDBC.java:77)
         at org.sqlite.JDBC.connect(JDBC.java:64)
         at java.sql.DriverManager.getConnection(DriverManager.java:582)
         at java.sql.DriverManager.getConnection(DriverManager.java:207)
         at com.accelatis.essbase.calcprofile.cdf.CalcComment.calcComment(CalcComment.java:16)
    >
    I've tried creating the policy using PolicyTool, same result. However, I have no idea what or if I should put in the "CodeBase" field.
    Has anyone had success creating read & write permissions to a single file using the udf.policy file? What is the magic syntax?
    Regards,
    Robb Salzmann
    * <font face="small" size=".2em" color="silver">right after the platinum star award is created</font>

    Hi Robb,
    Never heard of the OTN 25pt Platinum Star award... It sounds appetizing, but I know I won't get it since I've got no Java experience. :)
    I was just gonna ask if you've thought about posting the same question on one of the Java forums?
    https://forums.oracle.com/forums/category.jspa?categoryID=285
    Cheers,
    Mehmet

  • How to read/understand an user Trace Files

    Dear All,
    I am new to this forum, could any help me how to read/understand User Trace File
    Thanks,
    Kannan Pasupathi
    Edited by: 835519 on Feb 10, 2011 2:40 AM

    Hi,
    http://hoopercharles.wordpress.com/2009/12/01/10046-extended-sql-trace-interpretation/
    http://hoopercharles.wordpress.com/2010/01/26/10046-extended-sql-trace-interpretation-2/
    http://hoopercharles.wordpress.com/2010/09/06/10046-extended-sql-trace-interpretation-3/
    HTH
    Anand

  • Store User specific data in Secure file in EP

    Hi
        I wanted to store User specific data into Secure file .Please help me to access JAVA Secure Storage API 's of SAP netweaver
    Regards
    Ganesan S

    sorry, wrong post

  • I downloaded acrobat reader dc. after download completed, I could not open many PDF files. Error read: "could not open this file because its either not a supported file or because the file has been damaged". I opened a new user account and moved these fil

    I recently downloaded acrobat reader dc. After download was complete, I could not open PDF files. Error read "Adobe acrobat reader DC could not open this file because its either not a supported file or the file has been damaged". Any suggestions?

    HI davidd92392148,
    Is this error occurring for all PDF files that you try to open? There is an issue where all file icons can change to the PDF icon after installation, so is it possible that the files you're trying to open have been affected by this issue (and aren't actually PDF files)? Please see Application, file icons change to Acrobat/Reader icon.
    If that document isn't the key, then please tell us more about these files. Where are they stored? Did they open in previous versions of Reader?
    Best,
    Sara

  • New user- all my files are now read only -

    I am using a Dell Inspiron 8600 laptop with Windows XP  and my husband has a Dell Dimesion 4600 desktop.  Two weeks ago I installed a Linksys Compact Wireless-G USB adapter on his computer and then installed a WRT54G v.6 wireless router.  All is working fine for internet connection. Today I discovered all my files are now read only and even when I uncheck the read only box and click apply, then close the file, on re-opening it it is again read only.  Even the files on my external hard drive are now read only. 
    I am backtracking to see where a change was made that was unintended and the wireless router was the last thing I installed.  Is there a connection?  And if so, can someone help me make the necessary changes or tell me where to find out?
    I read through a lot of messages but did not immediately see this situation addressed. 
    Sandra

    seems to be an OS issue , because there is nothing on the router setting that could change the configuration on the computer....try System Restore....can't think of anything else at this point...

  • How to delete a specific file type from a folder

    Hi,
    I have folders with lots of zip or rar files, once I decompress those I want to delete the compressed files specifically. Is there any way I could manage that through Automator?
    Thanks in advance.

    Thanks Niel for the script, unfortunately I am too ignorant about running these on my own, I did save it in my user script library, but I would need instructions to run it. I would be really grateful.
    I did try making up my own workflow using the given actions in Automator, the first action was to 'find specific files in finder' ending with .zip and .rar and then choosing another action which 'moves selected files to trash'. Unfortunately it ended up running only if I specify the path to the specific .zip file, which defeats the purpose. Any suggestions on the proposed workflow? Thanks in advance.

  • Cannot delete specific files.

    I am unable to delete certain files, but I can delete others. Finder says "The operation cannot be completed because the item...is in use." I have tried:
    *Alt+Empty Trash
    *Secure delete
    *Empty trash from the Terminal
    *Repair permissions
    *Verify disk
    *Various utilities (Trash it!, OnyX, etc.)
    *Restart
    *Closed all applications
    I have noticed that if I try to delete from the Terminal it says "rm: /Users/mymacrules/.Trash/Cannot Delete/nl.lproj: Directory not empty". I also tried to move one file that would not delete from the trash, this file disappears when I click on it, but is there after restart. As long as that specific file is on the desktop it also makes another folder disappear. Even though I can't see it in Finder I can see it with the "ls" command. Any ideas?

    mymacrules wrote:
    I have noticed that if I try to delete from the Terminal it says "rm: /Users/mymacrules/.Trash/Cannot Delete/nl.lproj: Directory not empty".
    Right. The rm command by default will not delete nonempty directories. To force it to, use the recursive flag:
    rm -r /Users/mymacrules/.Trash/Cannot Delete/nl.lproj
    But keep in mind that I'm just a Unix person...people like Joshz who know MacOS better than me may know good reasons to not use the Terminal to try to empty the trash.

Maybe you are looking for

  • Why won't my divs stay fixed in Chrome after using adobe edge?

    Hi, Can someone help me with an Edge problem? I'm using: load: "http://cdn.edgecommons.org/an/1.0.0/js/min/EdgeCommons.js", complete: function() { EC.debug("Commons ready: "+EC.VERSION); EC.centerStage(sym); EC.Parallax.setup(sym); } }); to animate a

  • Can you select or disable AppleTV's audio output?

    I have my AppleTV connected to the television via HDMI and also connected to an amplifier via optical audio. I would like to disable the HDMI audio output as to not have the sound play through the television, but it does not appear to be configurable

  • How do I get my music onto my iPhone 4S it's not in my iTunes

    How do I get my music from iTunes it's not showing in purchased like it usually does

  • NoSuchElementExists runtime error

    This is going to be a bit long, so bear with me. I'm getting the following runtime error when I try to run the program: at java.util.StringTokenizer.nextToken(StringTokenizer.java:332) at MeetingMaker.load(MeetingMaker.java:185) at MeetingMaker.<init

  • Insert multiple rows using Cursors.

    I am trying to insert rows into a table based on information from another table. For example: When Table 1: Num_Rows = 100 my proc will insert 100 rows into Table 2 with relevent data. Do I need to use a Cursor and iterate through Num_Rows doing an I