local

Java logging api notes

JSP Notes

Eclipse FAQ

Programming guidelines

Satya - Saturday, March 04, 2006 10:27:37 AM

How can I get Stack trace as a string

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

satya - Wednesday, November 28, 2007 3:22:18 PM

serverside apis

serverside apis

satya - Thursday, May 12, 2011 1:12:33 PM

for loop structure


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

satya - Tuesday, August 16, 2011 10:26:33 AM

converting a charater to a string


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

satya - Tuesday, August 16, 2011 10:28:46 AM

walk througha string full of characters

walk througha string full of characters

satya - Thursday, August 25, 2011 9:26:09 AM

StringTokenizer

Search for: StringTokenizer

satya - Thursday, August 25, 2011 9:26:37 AM

Android StringTokenizer

Search for: Android StringTokenizer

satya - Thursday, August 25, 2011 9:26:52 AM

android StringSplitter

Search for: android StringSplitter

satya - Thursday, August 25, 2011 9:30:51 AM

Example


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

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

satya - Thursday, August 25, 2011 10:19:26 AM

creating a parameterized arraylist


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

satya - Thu Dec 27 2012 12:12:00 GMT-0500 (Eastern Standard Time)

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

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

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

satya - Thu Dec 27 2012 12:24:51 GMT-0500 (Eastern Standard Time)

You can do this


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

satya - Thu Dec 27 2012 12:27:33 GMT-0500 (Eastern Standard Time)

Here is how to use New IO: samples

Here is how to use New IO: samples

satya - Thu Dec 27 2012 12:28:27 GMT-0500 (Eastern Standard Time)

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

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

satya - Thu Dec 27 2012 15:26:53 GMT-0500 (Eastern Standard Time)

Here is one way to do this


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

satya - Thu Dec 27 2012 15:27:50 GMT-0500 (Eastern Standard Time)

readStreamAsString(InputStream is): A follow up method


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

satya - 6/23/2014 9:28:10 AM

String api in java

String api in java

satya - 6/23/2014 9:35:42 AM

java split string escape characters

java split string escape characters

Search for: java split string escape characters

satya - 6/23/2014 9:37:21 AM

what is a java Pattern class?

what is a java Pattern class

Search for: what is a java Pattern class

satya - 6/23/2014 9:37:28 AM

Pattern java class ref

Pattern java class ref

satya - 6/23/2014 10:06:11 AM

java array to arraylist conversion

java array to arraylist conversion

Search for: java array to arraylist conversion

satya - 6/23/2014 10:07:49 AM

java Arrays class reference

java Arrays class reference

Search for: java Arrays class reference

satya - 6/23/2014 10:08:19 AM

Here is the arrays reference

Here is the arrays reference