Help with program using hashtable to count words & other chars in txt file

I need to use only a hashtable to count the occurences words and chars in a text file and display them alphabetically. I am not to use anything but the hashtable. so far, I can get it to count only the words in the file and not the chars, I want to know how to make it count the chars (,.;:?(){}[]!@#$%^&\t\"<>/`~ ) that may be found and if it is possible to get it to display them in a sorted (alphabetical) order w/o using anything else.
This is what I have: mport java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
class words{
String word;
int count;
public class WordCount{
static Hashtable h=new Hashtable();
static words w;
static void countWords(String s){
if((w=(words)h.get((java.lang.Object)s))==null){
w=new words();
w.word=s;
w.count=1;
h.put(s,w);
}else{
w.count++;
h.remove(s);
h.put(s,w);
public static void main(String args[]){
String s;
StringTokenizer st;
String t;
String fn = JOptionPane.showInputDialog("Enter the filename:");
BufferedReader br = null;
try{
br = new BufferedReader(new FileReader(fn));
s=br.readLine();
while(s!=null){
st= new StringTokenizer(s, " ,.;:?(){}[]!@#$%^&\t\"<>/`~  ");
// Split your words.
while(st.hasMoreTokens()){
t=st.nextToken();
countWords(t);
s=br.readLine();
}catch(Exception e){
e.printStackTrace();
Enumeration e=h.elements();
w=(words)e.nextElement();
while(e.hasMoreElements()){
System.out.println(w.word + " " + w.count);
w=(words)e.nextElement();
System.exit(0);
}

Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

Similar Messages

  • Search help with programming

    Hai,
    Can any one give example for search help with Programming?
    I hope we can create search help with help of coding.
    With Regards,Jaheer.

    yes u can create search help by using match code in programs
    for eq
    go with abap editor se 38
    provide the name of program
    parameters : vendor like lfa1-lifnr matchcode object yzob.
    double click on yzob
    provide description for search help
    provide selection method
    provide search help parameter
    enable check box for import and export
    provide lpos
               spos
    save check activate
    press f4 for check and import values i.e it will display a records list available in database table
    rewards points please

  • Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Are you in DSL? Do you know if your modem is bridged?
    "Sometimes your knight in shining armor is just a retard in tin foil.."-ARCHANGEL_06

  • Can I use Bridge to export image data into a .txt file?

    I have a folder of images and I would like to export the File Name, Resolution, Dimensions and Color Mode for each file into one text file. Can I use Bridge to export image data into a .txt file?

    Hello
    You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
    set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
    use strict;
    use open IN => ':crlf';
    chdir $ARGV[0] or die qq($!);
    local $/ = qq(\\0);
    my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
    local $/ = qq(\\n);
    #     CSV spec
    #     - record separator is CRLF
    #     - field separator is comma
    #     - every field is quoted
    #     - text encoding is UTF-8
    local $\\ = qq(\\015\\012);    # CRLF
    local $, = qq(,);            # COMMA
    # print column header row
    my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
    print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    # print data row per each file
    while (@ff) {
        my $f = shift @ff;    # file path
        if ( ! open(IN, '<', $f) ) {
            warn qq(Failed to open $f: $!);
            next;
        $f =~ s%^.*/%%og;    # file name
        @dd = ('', $f, '', '', '', '');
        while (<IN>) {
            chomp;
            $dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
            ($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
            ($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
            ($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
            ($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
            last unless grep { /^$/ } @dd;
        close IN;
        print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
    EOF
    Hope this may help,
    H

  • Help With Program Please

    Hi everybody,
    I designed a calculator, and I need help with the rest of the scientific actions. I know I need to use the different Math methods, but what exactly? Also, it needs to work as an applet and application, and in the applet, the buttons don't appear in order, how can I fix that?
    I will really appreciate your help with this program, I need to finish it ASAP. Please e-mail me at [email protected].
    Below is the code for the calcualtor.
    Thanks in advance,
    -Maria
    // calculator
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class calculator extends JApplet implements
    ActionListener
    private JButton one, two, three, four, five, six, seven,
    eight, nine, zero, dec, eq, plus, minus, mult, div, clear,
    mem, mrc, sin, cos, tan, asin, acos, atan, x2, sqrt, exp, pi, percent;
    private JLabel output, blank;
    private Container container;
    private String operation;
    private double number1, number2, result;
    private boolean clear = false;
    //GUI
    public void init()
    container = getContentPane();
    //Title
    //super("Calculator");
    JPanel container = new JPanel();     
    container.setLayout( new FlowLayout( FlowLayout.CENTER
    output = new JLabel("");     
    output.setBorder(new MatteBorder(2,2,2,2,Color.gray));
    output.setPreferredSize(new Dimension(1,26));     
    getContentPane().setBackground(Color.white);     
    getContentPane().add( "North",output );     
    getContentPane().add( "Center",container );
    //blank
    blank = new JLabel( " " );
    container.add( blank );
    //clear
    clear = new JButton( "CE" );
    clear.addActionListener(this);
    container.add( clear );
    //seven
    seven = new JButton( "7" );
    seven.addActionListener(this);
    container.add( seven );
    //eight
    eight = new JButton( "8" );
    eight.addActionListener(this);
    container.add( eight );
    //nine
    nine = new JButton( "9" );
    nine.addActionListener(this);
    container.add( nine );
    //div
    div = new JButton( "/" );
    div.addActionListener(this);
    container.add( div );
    //four
    four = new JButton( "4" );
    four.addActionListener(this);
    container.add( four );
    //five
    five = new JButton( "5" );
    five.addActionListener(this);
    container.add( five );
    //six
    six = new JButton( "6" );
    six.addActionListener(this);
    container.add( six );
    //mult
    mult = new JButton( "*" );
    mult.addActionListener(this);
    container.add( mult );
    //one
    one = new JButton( "1" );
    one.addActionListener(this);
    container.add( one );
    //two
    two = new JButton( "2" );
    two.addActionListener(this);
    container.add( two );
    //three
    three = new JButton( "3" );
    three.addActionListener(this);
    container.add( three );
    //minus
    minus = new JButton( "-" );
    minus.addActionListener(this);
    container.add( minus );
    //zero
    zero = new JButton( "0" );
    zero.addActionListener(this);
    container.add( zero );
    //dec
    dec = new JButton( "." );
    dec.addActionListener(this);
    container.add( dec );
    //plus
    plus = new JButton( "+" );
    plus.addActionListener(this);
    container.add( plus );
    //mem
    mem = new JButton( "MEM" );
    mem.addActionListener(this);
    container.add( mem );
    //mrc
    mrc = new JButton( "MRC" );
    mrc.addActionListener(this);
    container.add( mrc );
    //sin
    sin = new JButton( "SIN" );
    sin.addActionListener(this);
    container.add( sin );
    //cos
    cos = new JButton( "COS" );
    cos.addActionListener(this);
    container.add( cos );
    //tan
    tan = new JButton( "TAN" );
    tan.addActionListener(this);
    container.add( tan );
    //asin
    asin = new JButton( "ASIN" );
    asin.addActionListener(this);
    container.add( asin );
    //acos
    acos = new JButton( "ACOS" );
    cos.addActionListener(this);
    container.add( cos );
    //atan
    atan = new JButton( "ATAN" );
    atan.addActionListener(this);
    container.add( atan );
    //x2
    x2 = new JButton( "X2" );
    x2.addActionListener(this);
    container.add( x2 );
    //sqrt
    sqrt = new JButton( "SQRT" );
    sqrt.addActionListener(this);
    container.add( sqrt );
    //exp
    exp = new JButton( "EXP" );
    exp.addActionListener(this);
    container.add( exp );
    //pi
    pi = new JButton( "PI" );
    pi.addActionListener(this);
    container.add( pi );
    //percent
    percent = new JButton( "%" );
    percent.addActionListener(this);
    container.add( percent );
    //eq
    eq = new JButton( "=" );
    eq.addActionListener(this);
    container.add( eq );
    //Set size and visible
    setSize( 190, 285 );
    setVisible( true );
    public static void main(String args[]){
    //execute applet as application
         //applet's window
         JFrame applicationWindow = new JFrame("calculator");
    applicationWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //applet instance
         calculator appletObject = new calculator();
         //init and start methods
         appletObject.init();
         appletObject.start();
    } // end main
    public void actionPerformed(ActionEvent ae)
    JButton but = ( JButton )ae.getSource();     
    //dec action
    if( but.getText() == "." )
    //if dec is pressed, first check to make shure there
    is not already a decimal
    String temp = output.getText();
    if( temp.indexOf( '.' ) == -1 )
    output.setText( output.getText() + but.getText() );
    //clear action
    else if( but.getText() == "CE" )
    output.setText( "" );
    operation = "";
    number1 = 0.0;
    number2 = 0.0;
    //plus action
    else if( but.getText() == "+" )
    operation = "+";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //minus action
    else if( but.getText() == "-" )
    operation = "-";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //mult action
    else if( but.getText() == "*" )
    operation = "*";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //div action
    else if( but.getText() == "/" )
    operation = "/";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //eq action
    else if( but.getText() == "=" )
    number2 = Double.parseDouble( output.getText() );
    if( operation == "+" )
    result = number1 + number2;
    else if( operation == "-" )
    result = number1 - number2;
    else if( operation == "*" )
    result = number1 * number2;
    else if( operation == "/" )
    result = number1 / number2;
    //output result
    output.setText( String.valueOf( result ) );
    clear = true;
    operation = "";
    //default action
    else
    if( clear == true )
    output.setText( "" );
    clear = false;
    output.setText( output.getText() + but.getText() );

    Multiple post:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=474370&tstart=0&trange=30

  • Can anyone help with programming co ordinates.

    how do i develop a class specification for class points.
    //pointTest.java
    main(...)     
         Point P1;
         P1.create(24,16); // create a point with coordinates {24,16}
         P1.display(); // display the {X,Y} coordinates of P1
    can anyone help with coding to program two points. can anyone elaborate on the stubs shown above to develop one point.

    There's already a Point class. So use that.
    Unless this is a homework in which case, well, it's your homework isn't it? So why are you asking us?

  • I need help with programs from my MacBookAir.

    Hello. I've intalled programs on my MacbookAit that I don't need anymore and I have no idea how to remove them from my laptop. I've been a PC user and I knew there how to remove them but here I just don't know. I know that dragging them to the trash won't work. I want to remove them and free the space that is taking. I hope you guys can help me with this. Thank you Very Much!!!

    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead.  Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
    AppZapper 2.0.1
    AppDelete 3.2.6
    Automaton 1.50
    Hazel
    AppCleaner 2.1.0
    CleanApp
    iTrash 1.8.2
    Amnesia
    Uninstaller 1.15.1
    Spring Cleaning 11.0.1
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • Help with embedding Type1 OTF Fonts in Word 2007/2010 docs

    Hi,
    I purchased a few Adobe OpenType Pro fonts including Myriad Pro and Garamond Pro. I want to use those fonts in Word 2007 and/or 2010 .docx type documents. It works fine while I work on my PC which has the fonts installed. Word recognizes the fonts and I can use them, in the 2010 version even with some OpenType features like ligatures, medieval numerals, etc. However, I have tremendous difficulties embedding those fonts so recipients can actually read and/or edit my documents.
    Exporting the fiels into PDF also skips embedding the fonts (at least as long as I use Microsofts PDF Export).
    Can someone please tell me:
    1) Is embedding of OpenType fonts in Word 2007 or 2010 possible at all?
    2) If not, can I trade in the fonts for the corresponding TrueType versions?
    3) If that is not possible, is there a way to convert the fonts into TrueType without losing too much of the font quality?
    Thank you all for your kind support.
    JP

    Microsoft only allows embedding of TrueType fonts and OpenType TrueType-flavored fonts to be embedded in their Office documents. There is nothing in OpenType CFF fonts (the OpenType fonts with Type 1 outlines in them) from being embedded in Office documents other than a business decision by Microsoft. Complain to them.
    No, Adobe does not provide its OpenType CFF fonts in OpenType TrueType format.
    No, there is no reasonable way to “convert” OpenType CFF fonts to OpenType TrueType format without some degradation of quality. Essentially you would be converting Bezier curves definition outlines in quadratic curve outlines and discarding the hinting which provides for intelligent scaling.
    I suggest you complain to Microsoft about this. Again, it is their business decision and pretty bone-headed one at that!
              - Dov 

  • Help with Sum using FormCalc in Livecycle

    Hello. I'm stuck. I've been doing searches, readings, and all that on how to sum up certain cells in Livecycle. I have tried examples and tutorials and I get stuck when the application says "Error: Accessor ' ' Unknown".
    I'm such a novice in using Livecycle and I'm not a programmer. So, if someone can help me on why it does this, that would be awesome!

    Here you go.  I rename it.  Couple of things.  Too many subforms (unless you intend to do something else with this).  Also, make sure you save your forms as "dynamic" if you intend to have user enter info.  I couldn't tell if you were importing/exporting to a spreadsheet.  Note the formcalc.  Your fields need to be named the same.  In my example they are: ExpCosts.
    I'm not very good with the formcalc/java and variables but am more than willing to help with what I can

  • Help with programming Ipad2

    I have an application that runs well in simulation on the mac. It requires the use of several .xml and other supporting files to run. My question is when I upload the application to the Ipad2, how do I transfer over the needed files. Also, how do I find the right pathways on the Ipad so that my program can access the right locations to run?
    Its a facial recognition application based upon Eigenfaces, requiring several files to manage the library, and not just the xcode.
    Thanks very much for the help.

    Don't assume simulator paths and device/iOS paths are identical. See Getting Paths to Application Directories
    Are the resources read only? If so, put them in the bundle, top level.
    How many are there?
    Is there a specific reason for using path'd sub-folders?
    How do you intend for them to be handled via iCloud?

  • Need help with session using dreamweaver

    have created a login page (php/mysql) with username and
    password boxes. when the form is submitted the mainpage loads up.
    i want the main page to be specific to that user, so i want
    their name to appear in the first line. eg.. Welcome back 'David'
    I read a tutorial in the past that tought me to send the
    users id in the URL and then create a record set on the mainpage
    that was filtered by the URL parameter.
    I have forgotten how to do this and the tutorial is no longer
    available on Adobe's site.
    I tried that with
    $_SESSION['MM_Username'] = $loginUsername; \\ in first page
    then
    echo $_SESSION["MM_username"]; \\in second page, but the
    problem is that is not showing user name.
    i need help with that please!
    can anyone tell me how to do this? Thanks in advance,
    AM

    IN the second page, you have to make sure that the session
    has been started.
    Put this at the very top of the page -
    <?php if (!isset($_SESSION)) session_start(); ?>
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Alidad" <[email protected]> wrote in
    message
    news:g184i4$jgf$[email protected]..
    > have created a login page (php/mysql) with username and
    password boxes.
    > when
    > the form is submitted the mainpage loads up.
    >
    > i want the main page to be specific to that user, so i
    want their name to
    > appear in the first line. eg.. Welcome back 'David'
    >
    > I read a tutorial in the past that tought me to send the
    users id in the
    > URL
    > and then create a record set on the mainpage that was
    filtered by the URL
    > parameter.
    >
    > I have forgotten how to do this and the tutorial is no
    longer available on
    > Adobe's site.
    >
    > I tried that with
    > $_SESSION['MM_Username'] = $loginUsername; \\ in first
    page then
    > echo $_SESSION["MM_username"]; \\in second page, but
    > the
    > problem is that is not showing user name.
    >
    > i need help with that please!
    >
    > can anyone tell me how to do this? Thanks in advance,
    >
    > AM
    >

  • Help with redirect using an HTML content variable

    Hi All,
    I have created an update_user page to update records in the
    table, and
    when submitted I want to be redirected to another "page". I
    really only
    have one page, an admin.php page, with one of the div's named
    "main".
    It uses the HTML content variable to replace the include file
    based on
    its name:
    > <?php
    > if (!isset($_REQUEST['content']))
    > include("main.inc.php");
    > else
    > {
    > $content = $_REQUEST['content'];
    > $nextpage = $content . ".inc.php";
    > include($nextpage);
    > } ?>
    So what I want to do now is redirect to something like the
    following:
    admin.php?content=userList
    I have tried replacing the value of the variable $updateGoTo
    shown below
    to include the content variable as shown above, but it
    doesn't work. So
    I think I'm not understanding the code below and that's
    preventing me
    from accomplishing what I want.
    > $updateGoTo = "admin.php";
    > if (isset($_SERVER['QUERY_STRING'])) {
    > $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" :
    > $updateGoTo .= $_SERVER['QUERY_STRING'];
    > }
    > header(sprintf("Location: %s", $updateGoTo));
    Can someone explain to me what the above code is doing, and
    what I need
    to do to accomplish my task?
    Many thanks.

    Micha,
    Thanks for your replies.
    > HTTP requires an absolute URL in the Location header.
    You have to add
    >
    http:// and the hostname.
    Why does the relative link work on my testing server as I had
    it listed
    before? Making the link absolute isn't any great problem, so
    I'll just
    do it.
    > 1) Don't use $_REQUEST, it contains mixed data from
    three different
    > sources. If you want to access URL parameters, use
    $_GET.
    >
    > 2) _Never_ trust any user-submitted data! The above code
    allows remote
    > code injection:
    >
    >
    http://example.com/admin.php?content=http://malicious.server/hackme
    >
    > Make sure that $_GET['content'] contains an allowed
    value, before you
    > use it in an include statement.
    Thanks for the pointer, I'll use $_GET instead. This is a
    password
    protected area that is only accessible to trusted users with
    admin
    privileges, so I would think they would be safe. However, on
    the public
    side I'll consider creating an allowable list for all HTML
    variables.
    Thanks.
    Brett

  • How to use automator to extract specific text from json txt file

    I'm trying to set up an Automator folder action to extract certain data from json files. I'm pulling metadata from YouTube videos, and I want to extract the Title of the video, the URL for the video, and the date uploaded.
    Sample json data excerpts:
    "upload_date": "20130319"
    "title": "[title of varying length]"
    "webpage_url": "https://www.youtube.com/watch?v=[video id]"
    Based on this thread, seems I should be able to have Automator (or any means of using a shell script) find data and extract it into a .txt file, which I can then open as a space delimited file in Excel or Numbers. That answer assumes a static number of digits for the text to be extracted, though. Is there a way Automator can search through the json file and extract the text - however long - after "title" and "webpage_url"?
    json files are all in the same folder, and all end in .info.json.
    Any help greatly appreciated!

    Hello
    You might try the following perl script, which will process every *.json file in current directory and yield out.csv.
    * CSV currently uses space for field separator as you requested. Note that Numbers.app cannot import such CSV file correctly.
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - *.json > out.csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    For Automator workflow, you may use Run Shell Script action as follows, which will receive json files and yield out_YYYY-MM-DD_HHMMSS.csv on desktop.
    Run Shell Script action
        - Shell = /bin/bash
        - Pass input = as arguments
        - Code = as follows
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - "$@" > ~/Desktop/out_"$(date '+%F_%H%M%S')".csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    Tested under OS X 10.6.8.
    Hope this may help,
    H

  • Help with RMI using inheritance program

    Hi all, im having trouble starting (and finding info on how to) to convert this program to use RMI. I have just completed re-structuring the program to use extended inheritance along with a Access Database.
    Whats the first step i need to take.
    Any help will be much appreciated. THANKS ALL
    import java.sql.*;
    import javax.swing.*;
    import java.util.*;
    public class Database {
       public java.sql.Connection connection;
       public void connect() 
          String url = "jdbc:odbc:groupTask2";  
          String username = "admin";   String password = "teama";
          // Load the driver to allow connection to the database
          try {
             Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
             connection = java.sql.DriverManager.getConnection(url, username, password );
          catch ( ClassNotFoundException cnfex ) {
             System.err.println("Failed to load JDBC/ODBC driver->"  + cnfex);
          catch ( SQLException sqlex ) {
             System.err.println( "Unable to connect->" + sqlex );
       public void showTeams()
          java.sql.Statement statement;
          java.sql.ResultSet resultSet;
          try {
             String query = "SELECT Team_name FROM Team_class";
             statement = connection.createStatement();
             resultSet = statement.executeQuery( query );
             displayResultSet( resultSet );
             statement.close();
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void showPlayers()
          java.sql.Statement statement;
          java.sql.ResultSet resultSet;
          String team = null;
          try {
             String s = JOptionPane.showInputDialog("Please select Team: \n\n1. Panthers \n2. Quails \n3. Bears \n4. Nevils \n ");
             int a = Integer.parseInt(s);
             switch (a){
                 case 1: team = "Panthers";
                         break;
                 case 2: team = "Quails";
                         break;
                 case 3: team = "Bears";
                         break;
                 case 4: team = "Nevils";
                         break;
             String query = "SELECT player_id, First_name, Last_name FROM Player_class WHERE Team_name LIKE '"+team+"'";
             statement = connection.createStatement();
             resultSet = statement.executeQuery( query );
             displayResultSet( resultSet );
             statement.close();
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void update()
          java.sql.Statement statement;
          java.sql.Statement statement2;
          java.sql.ResultSet resultSet;
          String field = null;
          try {
             String a = JOptionPane.showInputDialog("Please Enter the player ID:");
             int id = Integer.parseInt(a);
             String b = JOptionPane.showInputDialog("Which field would you like to update? \n\n1. First name \n2. Last name \n3. Address \n ");
             int choice = Integer.parseInt(b);
             switch (choice){
                 case 1: field = "First_name";
                         break;
                 case 2: field = "Last_name";
                         break;
                 case 3: field = "address";
                         break;
             String val = JOptionPane.showInputDialog("Please enter new " +field);
             String query = "UPDATE Player_class SET "+field+" = '"+val+"' WHERE player_id = "+id;
             statement = connection.createStatement();
             statement.executeQuery( query );
             statement.close(); 
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void displayResultSet( ResultSet rs )
          throws SQLException
          // position to first record
          boolean moreRecords = rs.next();  
          // If there are no records, display a message
          if ( ! moreRecords ) {
                System.out.println( "ResultSet contained no records" );
                return;
          System.out.println( "" );
          try {
             java.sql.ResultSetMetaData rsmd = rs.getMetaData(); 
             // Get column heads
             for ( int i = 1; i <= rsmd.getColumnCount(); ++i ) {
                 System.out.print(rsmd.getColumnName( i ) + "\t");
             System.out.println();
             do {// get row data
                  displayNextRow( rs, rsmd );
             } while ( rs.next() );
          catch ( SQLException sqlex ) {
             sqlex.printStackTrace();
       public void displayNextRow( ResultSet rs, 
                                  ResultSetMetaData rsmd )
           throws SQLException
          for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
             switch( rsmd.getColumnType( i ) ) {
                case java.sql.Types.VARCHAR:
                      System.out.print (rs.getString( i )+"\t\t" );
                   break;
                case java.sql.Types.INTEGER:
                      System.out.print ( rs.getLong( i ) + "\t\t") ;
                   break;
                default: 
                   System.out.println( "Type was: " + 
                      rsmd.getColumnTypeName( i ) );
             System.out.println();
       public void shutDown()
          try {
             connection.close();
          catch ( SQLException sqlex ) {
             System.err.println( "Unable to disconnect->" + sqlex );
       public static void main( String args[] ) 
           int sel = 0;
           Menu M = new Menu();
           Database app = new Database();
           sel = M.mainmenu(sel);
           while (sel > 0 && sel < 5){
           switch (sel){
               case 1: app.connect();
                       app.showTeams();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
               case 2: app.connect();
                       app.showPlayers();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
               case 3: app.connect();
                       app.update();
                       app.shutDown();
                       sel = M.mainmenu(sel);
                       break;
    class Menu{ 
        int choice = 0;
        int temp = 0; 
        public Menu(){
        public int mainmenu(int val){ 
            String a = JOptionPane.showInputDialog("TEAM MENU \n\nPlease select an option by entering " + 
                    "the corresponding number: \n\n1. Display Teams \n2. Show Players \n3. Update a Player \n4. Search \n "); 
            val= Integer.parseInt(a); 
            return val; 
        public int setChoice(int val){
            choice = val;
            return choice;

    Well, I'd say a starting point is to split the functionality into "client" and "server". This will wind up as two programs, the client making - remote - requests of the server.
    A fairly natural way would be to assign viewing/display to the client, direct access to the database to the server. So then you have to figure out
    o what kinds of requests can go acrross the divide.
    o what kind of data will be returned.
    This may not be that easy, because things that the server can do easily (like I/O) cnnot be carried back and forth in RMI calls.)

  • Help with Program creation that deletes deliveries by using VL02

    Hi,
    Can anyone guide me on creating a program based on the following requirement:
    Select-Options: Sales Org, Distribution Channel, Customer
    Read data from KNVV where Sales Org = <input from selection screen>
    Based on the data read, find the said documents with delivery type LO in table LIKP.
    For each document found, delete the documents by processing VL02 (background)
    How can I create this? <b>Are any BAPI's available to do this?</b>
    Here is the code that i have so far:
    TABLES: KNVV.
    DATA: I_KNVV LIKE KNVV OCCURS 0 WITH HEADER LINE,
          I_LIKP LIKE LIKP OCCURS 0 WITH HEADER LINE.
    SELECT-OPTIONS: S_VKORG FOR KNVV-VKORG,
                    S_VTWEG FOR KNVV-VTWEG,
                    S_KUNNR FOR KNVV-KUNNR.
    SELECT * INTO TABLE I_KNVV FROM KNVV
    WHERE VKORG IN S_VKORG AND
          VTWEG IN S_VTWEG AND
          KUNNR IN S_KUNNR.
    SELECT * INTO TABLE I_LIKP FROM LIKP
    FOR ALL ENTRIES IN I_KNVV
    WHERE VKORG = I_KNVV-VKORG
    AND LFART = 'LO'.
    All Detailed answers will be rewarded and greatly appreciated.
    Thanks,
    John

    I wrote simple program and test it ur system..
    I have tested in 4.6C Version.
    REPORT ZVBPA_MOD.
    TABLES: KNVV.
    data : bdcdata like bdcdata occurs 0 with header line.
    DATA: I_KNVV LIKE KNVV OCCURS 0 WITH HEADER LINE,
    I_LIKP LIKE LIKP OCCURS 0 WITH HEADER LINE.
    SELECT-OPTIONS: S_VKORG FOR KNVV-VKORG,
    S_VTWEG FOR KNVV-VTWEG,
    S_KUNNR FOR KNVV-KUNNR.
    start-of-selection.
    SELECT * INTO TABLE I_KNVV FROM KNVV
    WHERE VKORG IN S_VKORG AND
    VTWEG IN S_VTWEG AND
    KUNNR IN S_KUNNR.
    SELECT * INTO TABLE I_LIKP FROM LIKP
    FOR ALL ENTRIES IN I_KNVV
    WHERE VKORG = I_KNVV-VKORG
    AND KUNNR = I_KNVV-KUNNR
    AND LFART = 'LO'.
    loop at I_LIKP.
    perform bdc_dynpro      using 'SAPMV50A' '0101'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LIKP-VBELN'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LIKP-VBELN'
                                  I_LIKP-vbeln.
    perform bdc_dynpro      using 'SAPMV50A' '0200'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/ELOES'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LIKP-VBELN'.
    call transaction 'VL02' using bdcdata
                               mode 'N'
                               update 'S'.
    ENDLOOP.
           Start new screen                                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
           Insert field                                                  *
    FORM BDC_FIELD USING FNAM FVAL.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
    ENDFORM.

Maybe you are looking for

  • Need all Driver for HP Pavilion-15ab027tx Model for windows 64 bit

    Please help me! , I need driver for the hp pavilion 15-ab027tx Model for windows 7 64 bit. display Adapter: PCI\VEN_8086&DEV_1616&SUBSYS_8099103C&REV_09 PCI\VEN_8086&DEV_1616&SUBSYS_8099103C PCI\VEN_8086&DEV_1616&CC_030000 PCI\VEN_8086&DEV_1616&CC_03

  • Cannot open ACR preferences in bridge

    I get the 'qualifying product' error.  I have updated it to the latest ACR, opened PS4 first, and luanched bridge from there...all with no luck. Is tehre a dead link somewhere that needs to be fixed?  ACR is in the right folder and everything. I have

  • Auto created import statements

    I create a var of some type and the builder adds the import statement and then if I change the type later on it adds another import statement, is there a way to cleanup the unused import statements? Thanks, Mike

  • Unable to load provider data?

    Hello everyone,   Everytime I plug in my iPod touch, I get the message: iTunes was unable to load provider data from sync services.  Reconnect and try sgain later. What isn't happening?  It says at the top of the screen that it is syncing, but is it

  • Error in games and video not runnning properly

    When I start game it shows an error that either hardware accleration is disabled or video card is no supported. Afetr that game is running slowly. For video it shows colored dots in video and video also plays slow. I think its also because of same pr