Custom workspace path:
Configuration \ config. ini osgi. instance. area. Default = @ user. Home/workspace
Eclipse Program Interface beautification Technology
Http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-rcprich/
Java reads and writes files according to the specified Encoding
Arraylist <string> namearr = new arraylist ();
Stringbuilder builder = new stringbuilder ();
Try {
String txtpath = "C: \ name 2.txt ";
String txtnewpath = "C: \ name 3.txt ";
Bufferedreader reader = new bufferedreader (New inputstreamreader (
New fileinputstream (txtpath), "GBK "));
String line = NULL;
Boolean first = true;
While (line = reader. Readline ())! = NULL ){
String [] names = line. Split ("");
For (string name: names ){
If (name. Length ()> 2)
{
Name = Name. Replace ("city", ""). Replace ("Autonomous County ","");
Name = Name. Replace ("Autonomous Region ","");
Name = Name. Replace ("County ","");
Name = Name. Replace ("Province ","");
If (name. indexof ("city")> 0)
{
String [] newnames = Name. Split ("city ");
If (newnames = NULL)
Continue;
If (newnames. Length = 1)
Name = newnames [0];
Else
Name = newnames [1];
}
}
If (namearr. indexof (name) =-1)
{
Namearr. Add (name );
Builder. append (name + "\ r \ n ");
}
}
}
Reader. Close ();
Bufferedwriter writer = new bufferedwriter (New outputstreamwriter (
New fileoutputstream (txtnewpath ),"GBK"));
Writer. Write (builder. tostring ());
Writer. Close ();
} Catch (filenotfoundexception e ){
E. printstacktrace ();
} Catch (ioexception e ){
E. printstacktrace ();
}
Java RCP development to obtain files under the application Workspace
/**
* Obtain the database path
* @ Return
*/
Public static string getdb (){
Location instancelocation = platform. getinstancelocation ();
URL path = instancelocation. geturl ();
String strpath = path. getpath () + "Gs. DB ";
Return strpath;
}
Obtain the startup path of the RCP Application
File bundlefile = NULL;
Try {
Bundlefile = filelocator. getbundlefile (activator. getdefault (). getbundle ());
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
If (bundlefile = NULL)
Return NULL;
File geosearchfolder = bundlefile. getabsolutefile ();
String geosearchdisk = geosearchfolder. getparent ();
Obtain the corresponding view object based on The View ID.
String viewid = "com. geocompass. geosearch. Views. filejudger ";
Iviewpart part = platformui. getworkbench (). getactiveworkbenchwindow (). getactivepage (). findview (viewid );
Filejudgerview judgeview = (filejudgerview) part;
Judgeview. reloaddata ();
Java Open folder:
Java. AWT. desktop. getdesktop (). Open (NewFile ("D: \ Java"));
Delete folders and folder content
Public void deletefile (File targetfile)
{< br> If (targetfile. isdirectory ()
{< br> file [] list = targetfile. listfiles ();
for (INT I = 0; I deletefile (list [I]);
}< br> //
targetfile. deleteonexit ();
}< br> else
targetfile. deleteonexit ();
}