[Building Sakai] File in Sakai

Steve Swinsburg steve.swinsburg at gmail.com
Wed May 26 15:00:19 PDT 2010


Hi,

This isn't Sakai specific. The javadocs for File.createTempFile() show this:

public static File createTempFile(String prefix,
                                  String suffix)
                           throws IOException
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. Invoking this method is equivalent to invokingcreateTempFile(prefix, suffix, null).

Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used

So the name is generated from the prefix and suffix. 

You can also give a third param which is the directory where the file is to be created, defaulting to the system temp dir if null, varies between platforms.

If you actually need to create files in Sakai, have a look at the ContentHostingService.

cheers,
Steve



On 27/05/2010, at 4:05 AM, le tan vu wrote:

> Hello everyone
> I'm using Sakai 2.6.0
> With java.io.File, I'm trying to make some new file at temp directory of tomcat. In order to do that, I use File.createTempFile(prefix,subfix) function. But it gives me a file with a strange name, not the filename I want.
> Another way, I use createNewFile() function but it makes new file in bin directory of tomcat.
> 
> How I can make new file at temp directory and exact name I want?
> 
> Is there any solution which can work around?
> 
> Thanks in advanced and best regards.
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
> 
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100527/963e05c5/attachment.html 


More information about the sakai-dev mailing list