WAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreWAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 15th, 2004, 08:00 PM
guiding5 guiding5 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 guiding5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
WML Index creator (1st try with Java)

Wanted to make bit easier uploading some media to my phone from my HTTP site.

This program makes WML index for files(any) in specific folder.

Though it could be usefull, at least as example for bad Java code :P


Code:
/*
 * MakeTags.java
 *
 * Created on August 15, 2004, 10:11 PM
 */


import java.io.*;
import javax.swing.*;

/**
 *
 * @author  Guiding5
 */
public class MakeTags
{
    
    /** Creates a new instance of MakeTags */
    public MakeTags()
    {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
	File file = null ;
	if (args.length > 0)
	{
	    // allow a file to be specified via the command
	    // line (for testing)
	    file = new File(args[0]) ;
	}
	else
	{
	    // allow the user to browse for a file if one was not
	    // specified at the command line
	    
	    /*
	    JFileChooser jfc = new JFileChooser() ;
	    jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

	    int result = jfc.showOpenDialog(null) ;
	    if (result == jfc.CANCEL_OPTION)
	    {
		System.exit( 0 ) ;
	    }
	    
	    File dir = jfc.getSelectedFile();
	     */
	    
	    File dir = new File("D:\\nokia\\down");
	    if (!dir.isDirectory())
	    {
		System.out.println("Have to be Directory !");
		System.exit( 0 ) ;
	    }
	    
	    PrintWriter pww = null;
	    File files[] = dir.listFiles();
	    
	    try
	    {
		pww = new PrintWriter(new FileWriter("D:\\nokia\\down\\down.wml"));
	    }
	    catch (Exception e)
	    {
		System.out.println("Cant init output !!!");
		System.exit( 0 ) ;
	    }
	    
	    ///PrintStream pww = System.out;
	    pww.println("<?xml version=\"1.0\"?>");
	    pww.println("<!DOCTYPE wml PUBLIC \"//DTD WML 1.1//EN\" \"http://www.you.org/down.wml\">");
	    pww.println("    <wml>");
	    pww.println("        <card title=\"Miscellaneous\">");
	    pww.println("        <p>Select file to download:</p>");
	    
	    for(int i=0; i<files.length; i++)
	    {
		File current = files[i];
		if(current.isFile() && current.getName() != "down.wml")
		{
		    pww.println("        <p><a href=\""+current.getName()+"\">"
				    +current.getName()+"</a></p>");
		}
	    }
	    
	    pww.println("    </card>");
	    pww.println("</wml>");
	    pww.flush();
	    System.out.flush();
	}
    }
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > WML Index creator (1st try with Java)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway