local

Java logging api notes

JSP Notes

Eclipse FAQ

Programming guidelines

	public static String getStackTrace(Throwable t)
	{
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		PrintWriter pw = new PrintWriter(bos);
		t.printStackTrace(pw);
		String output = pw.toString();
		pw.close();
		return output;
	}

serverside apis


for(String s :strings)
{
 r.reportBack(tag, "Processing:" + s);
}

char c = 'a';
String s = Character.toString(c);

walk througha string full of characters

Search for: StringTokenizer

Search for: Android StringTokenizer

Search for: android StringSplitter


TextUtils.StringSplitter splitter = 
   new TextUtils.SimpleStringSplitter(delimiter); 

// Once per string to split 
splitter.setString(string); 
for (String s : splitter) 
{     
   ... 
}

ArrayList<String> al = new ArrayList<String>();

How to write a string to file output stream in Java?

Search for: How to write a string to file output stream in Java?


String inputString;
FileOutputStream fos;
fos.write(inputString.getBytes());

Here is how to use New IO: samples

Here is how to use new IO to save string to a file


static public void copy(InputStream reader, OutputStream writer)
      throws IOException
   {
        byte byteArray[] = new byte[4092];
         while(true)
         {
            int numOfBytesRead = reader.read(byteArray,0,4092);
            if (numOfBytesRead == -1)
            {
               break;
            }
            // else
            writer.write(byteArray,0,numOfBytesRead);
         }
         return;
   }

static public String readStreamAsString(InputStream is)
      throws FileNotFoundException, IOException
   {

      ByteArrayOutputStream baos = null;
      try
      {
         baos = new ByteArrayOutputStream();
         copy(is,baos);
         return baos.toString();
      }
      finally
      {
         if (is !=null)
         {
            FileUtils.closeStream(is);
         }
         if (baos != null)
            com.ai.common.FileUtils.closeStream(baos);
      }
   }

String api in java

java split string escape characters

Search for: java split string escape characters

what is a java Pattern class

Search for: what is a java Pattern class

Pattern java class ref

java array to arraylist conversion

Search for: java array to arraylist conversion

java Arrays class reference

Search for: java Arrays class reference

Here is the arrays reference