Check11C - { if (index.startsWith(variable)) { index =

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; import java.util.*; import java.net.URLDecoder; import java.nio.charset.Charset; i public class Check11C { public static void main(String[] args) throws Exception { PrintStream out = System.out; Scanner in = new Scanner(System.in); out.println("Enter the query string: "); String query = in.nextLine(); out.println("Enter the variable name:"); String variable = in.nextLine(); args = query.split("&"); try { boolean flag = false; for (String index : args)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { if (index.startsWith(variable)) { index = index.substring(index.indexOf("=") + 1); out.println("Before decoding: \n" + index); index = URLDecoder.decode(index, "UTF-8"); out.println("After decoding: \n" + index); throw new Exception(""); } else { flag = true; } } if (flag) { throw new Exception("No such variable \"" + variable + "\"!"); } } catch (Exception e) { out.println(e.getMessage()); } } }...
View Full Document

Ask a homework question - tutors are online