Java eclipse RCP

Source: Internet
Author: User

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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.