apache-commons

How to check if FileObject is folder?

I'm using Apache Commons VFS (Virtual File System) to access some files over SFTP. Does anybody know how to check if an instance of org.apache.commons.vfs.FileContent is folder? ...

Unit testing with multiple collaborators

Today I ran into a very difficult TDD problem. I need to interact with a server through HTTP POSTs. I found the the Apache Commons HttpClient, which does what I need. However, I end up with a bunch of collaborating objects from Apache Commons: public void postMessage(String url, String message) throws Exception { PostMethod post =...

Apache Commons IO in .Net

Is there a library like Apache Commons IO for .Net? I am looking for the following functions: IOUtils.toByteArray(Stream); IOUtils.toString(Stream); FileUtils.write*(); DirectoryWalker. ...

Is there an implementation of org.apache.commons.lang.Validate for .Net ?

Is there an implementation of org.apache.commons.lang.Validate for .Net ? ...

Python equivalent of PropertyUtilsBean

Hi everyone! I was wondering, is there a Python equivalent to Apache commons' PropertyUtilsBean? Edit: For example, I'd like to be able to make this assignment x.y[2].z = v given "y[2].z" as a string. Please note, I'm asking just because I'd like to not reinvent the wheel :) ...

Java TelnetClient hangs at “press any key to continue”

I have a Java program that runs on Linux and telnets into a remote server using org.apache.commons.net.telnet.TelnetClient and performs a few commands. The problem is that it hangs intermittently when it gets to an output display that asks the users to “press any key to continue…” The program hangs on this about 1 out of every 10 tims ...

Can I get the response server name/ip using Apache HttpClient?

I'm using Apache HttpClient 3.x for contacting a Big IP that will then redirect my request to one of 1-N machines. We have the need to know which of the N machines actually picked up the request though, and I'm not sure how to get this information. I looked through the Response headers with no luck, so I'm wondering if this information...

Apache Date Validator Pattern Question

Hi all. I am using org.apache.commons.validator.routines.DateValidator to validate a date with a simple date pattern "dd/mm/yyyy" Unfortunate part is that if I pass a date in format "2/2/1992" then it declares it as an invalid date and if I use format "d/m/yyyy" (In java SimpleDateFormat both these formats works for both cases), then ...

Multiple Linear Regression

I am trying to use GLSMultipleLinearRegression (from apache commons-math package) for multiple linear regression. It is expecting a covariance matrix as input -- I am not sure how to compute them. I have one array of dependent variables and 3 arrays of independent variables. Any idea how to compute the covariance matrix? Note: I have 2...

Preventing HttpClient 4 from following redirect

I'm connecting to my AppEngine application using the Apache HttpComponents library. In order to authenticate my users, I need to pass an authentication token along to the application's login address (http://myapp.appspot.com/%5Fah/login?auth=...) and grab a cookie from the header of the response. However, the login page responds with a...

Commons Digester add Singleton Object

Hi I Have a XML and I am using commons-digester1.8 to create a object of my bean. My bean contains a reference to another Bean which is singleton. Is there any way I can create/get the reference of singleton object and get my bean populated. My xml contains <>/language tag and for this tag bean has Language.class reference. Language.cl...

How to Serialize a list in java?

I would like to deep clone a List. for that we are having a method SerializationUtils.clone ( object ) // apache commons method. Object shld be serializable so now to clone my List i should convert that to serializable first. Is it possible to convert a List into Serializable list? ...

Difference between Socket.connect(Adreess,timeout) and FTPClient.setSoTimeOu

We are doing FTP connection through our applicaion which is a JAVA aplication. We have set timeout for connection using Socket.connect(Adreess,timeout) method before calling FTPClient.connect() method. During retriving files from the FTP site under same connection we havent set any timeout. Is it mandatory to call method FTPClient.setSo...

Apache Commons SCXML State Machine Framework

Hello I'm attempting to define a state machine for a Java application using Apache SCXML. However, I've run into a problem and I'm not sure if this is due to the SCXML framework or me doing something wrong. I'm basing my test application on the following example (without the android bit): http://commons.apache.org/scxml/usecases/scxml-s...

FTPSClient authentication to an FTP server using a digital certificate or private key

I have a working prototype of a Java application that is using Apache Commons Net FTPSClient to connect to a FileZilla server over SSL (port 990 for what it is worth). No problem. The problem is, the application is currently maintaining the credentials of the FTP user in the form of a username and password. Is it possible to perform au...

Apache Commons vs. Google Collections

I was looking for a bidirectional map implementation in Java, and stumbled upon these two libraries: Apache Commons Collections Google Collections Both are free, have the bidirectional map implementation that I was looking for (BidiMap in Apache, BiMap in Google), are amazingly nearly the same size (Apache 493 kB, Google 499 kB) and ...

file upload "multipart/form" Exception org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException

I tried to use the file upload using Apache Commons but the following exception thrown org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null My html code is <form name="inp" action="upload.jsp" method="get" on...

Parse into HashMap using Commons Digester

I need to parse xml into a HashMap where the 'key' is the concatenation of two elements attributes. The xml looks like : <map> <parent key='p1'><child key='c1'> value1</child></parent> <parent key='p2'><child key='c2'> value1</child></parent> </map> In the 1st entry of map, I want to put 'p1.c1'as the map key while 'value1' as the...

Apache Commons Fileupload / Tomcat cant cope with out.flush()

Does anyone know of a workaround whereby if you are trying to flush the servlet output stream, apache commons fileupload throws the following exception? FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly Basically I have code that loops through each file uploaded using apache commons fileu...

Is the Apache Commons Collections framework faster than the JDK collections framework?

I have always been using the stock JDK collections in my code. Does the Apache Commons Collections framework run faster? ...