commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Kitching (JIRA)" <j...@apache.org>
Subject [jira] Closed: (DIGESTER-128) When using Digester parsed a file with a directory that contained chinese charset it will throw java.net.MalformedURLException.
Date Mon, 25 Aug 2008 07:49:44 GMT

     [ https://issues.apache.org/jira/browse/DIGESTER-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Simon Kitching closed DIGESTER-128.
-----------------------------------

    Resolution: Invalid

Not a bug.

> When using Digester parsed a file with a directory that contained chinese charset it
will throw java.net.MalformedURLException.
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIGESTER-128
>                 URL: https://issues.apache.org/jira/browse/DIGESTER-128
>             Project: Commons Digester
>          Issue Type: Bug
>    Affects Versions: 1.7
>         Environment: Windows XP
> Eclipse 3.2
>            Reporter: jzwang
>            Priority: Critical
>
> When I try to use Digester to parser a file I found if the file is in a directory with
Chinese(such as c:/tmp/中文/datasource.xml) char set it will throw java.net.malformedURLException.
> My code is here.
> -------------------- SampleDigester.java -------------------
> import java.io.IOException;
> import java.util.Hashtable;
> import org.apache.commons.digester.Digester;
> import org.xml.sax.SAXException;
> public class SampleDigester
> {
>   private Hashtable dataSources = new Hashtable();
>   public static void main(String[] args)
>   {
>     SampleDigester sample = new SampleDigester();
>     try
>     {
>       sample.run();
>     }
>     catch(Exception e)
>     {
>       e.printStackTrace();
>     }
>   }
>   public void run() throws IOException, SAXException
>   {
>     Digester digester = new Digester();
>     digester.push(this);
>     digester.addCallMethod("datasources/datasource", "addDataSource", 5 );
>     digester.addCallParam("datasources/datasource/name", 0);
>     digester.addCallParam("datasources/datasource/driver", 1);
>     digester.addCallParam("datasources/datasource/url", 2);
>     digester.addCallParam("datasources/datasource/username", 3);
>     digester.addCallParam("datasources/datasource/password", 4);
> //    digester.parse("datasource.xml"); // ok
>     digester.parse("c:/tmp/中文/datasource.xml"); // failed
> //    digester.parse("c:/tmp/a b/datasource.xml"); // ok
>   }
>   public void addDataSource(String name,
>                             String driver,
>                             String url,
>                             String userName,
>                             String password)
>   {
>     DataSource dataSource = new DataSource(name, driver,url, userName, password);
>     dataSources.put(name, dataSource);
>     System.out.println("DataSource added: " + name);
>   }
> }
> --------------------------- DataSource.java ---------------------
> public class DataSource
> {
>   private String name;
>   private String driver;
>   private String url;
>   private String password;
>   private String userName;
>   public DataSource(String name, String driver, String url, String userName, String password)
>   {
>     this.name = name;
>     this.driver = driver;
>     this.url = url;
>     this.userName = userName;
>     this.password = password;
>   }
>   public String getName()
>   {
>     return name;
>   }
>   public String getDriver()
>   {
>     return driver;
>   }
>   public String getURL()
>   {
>     return url;
>   }
>   public String getPassword()
>   {
>     return password;
>   }
>   public String getUserName()
>   {
>     return userName;
>   }
> }
> --------------------------- DataSource.xml -------------
> <?xml version="1.0"?>
> <datasources>
>   <datasource>
>     <name>HsqlDataSource</name>
>     <driver>org.hsqldb.jdbcDriver</driver>
>     <url>jdbc:hsqldb:hsql://localhost</url>
>     <username>sa</username>
>     <password></password>
>   </datasource>
>   <datasource>
>       <name>OracleDataSource</name>
>       <driver>oracle.jdbc.driver.OracleDriver</driver>
>       <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>       <username>scott</username>
>       <password>tiger</password>
>   </datasource>
> </datasources>
> ----------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message