JavaRanch Home    
 
This page:         last edited 26 August 2010         What's Changed?         Edit

Java I/O FAQ   

This page is the FAQ for the "I/O and Streams" forum. It's editable by everyone, so add your own content as you see fit.

Other FAQ pages that deal with I/O

  • The FileUpload page has hints on how to upload files to a server via FTP, SMB and HTTP.



Links to articles elsewhere that relate to I/O

  • Character Conversions from Browser to Database: article

  • Using ICMP packets (for ping and traceroute) in Java: Jpcap library



Where can I get an implementation of the javax.comm API for Windows?

Sun does not provide an implementation of javax.comm version 3 for Windows, but version 2 can be used in conjunction with RXTX; see the javax.comm download page for further information. Other options (which do not implement the javax.comm API) are



When I try to construct an HTTPS URL, I get a java.net.MalformedURLException: unknown protocol: https. What gives?

JDK versions prior to 1.4 do not have HTTPS/SSL built in - they need an additional package called JSSE. Installation instructions can be found here. Then the JVM needs to be told what to do with HTTPS URLs, which can be done programmatically like this:

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
//System.setProperty("https.proxyHost", proxyHost);
//System.setProperty("https.proxyPort", proxyPort);

Alternatively, you can specify this as a property on the command line:

 -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol


How can I set the client timeout when making an URL connection?

Starting with Java 5, this functionality is available in the JavaDoc:java.net.URLConnection class and its subclasses (like HttpURLConnection) via the getConnectTimeout/setConnectTimeout methods. For older Sun JVMs, a workaround is described here.

Jakarta Commons HttpClient also supports setting a timeout.


How can I check the type of an image file?

The freely available ImageInfo class can identify certain image types: JPEG, PNG, GIF, BMP, PCX, IFF, RAS, PBM, PGM, PPM and PSD. It also determines certain image properties like height, width and color depth.


How can I send SMS from a Java application?

You'll need an SMS library like smsj, SMSLib or smstools and a provider. You can find the latter by googling for "bulk sms http". This article may also be of interest.


How can I use a modem from within Java? (or, to put it in another way, is there an implementation of JTAPI?)

The http://xtapi.sourceforge.net/ project "has providers for Microsoft’s TAPI, Serial Voice Modems, and Voice Over IP utilizing the OpenH323? Projects H.323 stack implementation".


How can I determine the encoding of a given file?

That's what the jchardet and juniversalchardet libraries do.


CategoryFaq

JavaRanchAbout us — Copyright © 1998-2010 Paul Wheaton