Java Code – Convert a file to a String

How to read file content into a string? The following is the Java code to do that. To make it work, the filePath need to be changed. public static String readFileToString() throws IOException { File dirs = new File("."); String filePath = dirs.getCanonicalPath() + File.separator+"src"+File.separator+"TestRead.java";   StringBuilder fileData = new StringBuilder(1000);//Constructs a string buffer with … Read more

Eclipse SWT and JFace widgets references

If you want to develop Java Desktop application, you probably have two choices of libraries: SWT vs. Swing. Where there is pros and cons for both of them, here is a comparison between them. Recall the role of Standard Widget Tootlkit (SWT) in eclipse platform below. JFace is a high-level user interface(UI) widget library built … Read more

Java Access Level for Members: public, protected, private

Java access level contains two parts: 1) access level for classes and 2) access level for members. For class access level, the keyword can be public or no explicit modifier(package-private). For member access level, the keyword can be public, protected, package-private (no explicit modifier), or private. The following table summarizes the access level of different … Read more