List of usage examples for java.io DataOutputStream writeBytes
public final void writeBytes(String s) throws IOException
From source file:Main.java
public static Process runSuCommandAsync_spica2(Context context, String command) throws IOException { DataOutputStream fout_spica2 = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_spica2, 0)); fout_spica2.writeBytes(command); fout_spica2.close();// ww w . j av a2 s . c om String[] args_spica2 = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_spica2 }; Process proc_spica = Runtime.getRuntime().exec(args_spica2); return proc_spica; }
From source file:Main.java
public static String executePost(String url, String parameters) throws IOException { URL request = new URL(url); HttpURLConnection connection = (HttpURLConnection) request.openConnection(); connection.setDoOutput(true);//from w w w . ja v a 2 s . c om connection.setDoInput(true); connection.setInstanceFollowRedirects(false); connection.setRequestMethod("POST"); connection.setRequestProperty("User-Agent", "StripeConnectAndroid"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("Content-Length", "" + Integer.toString(parameters.getBytes().length)); connection.setUseCaches(false); DataOutputStream wr = new DataOutputStream(connection.getOutputStream()); wr.writeBytes(parameters); wr.flush(); wr.close(); String response = streamToString(connection.getInputStream()); connection.disconnect(); return response; }
From source file:Main.java
public static Process runSuCommandAsync_miracle(Context context, String command) throws IOException { DataOutputStream fout_miracle = new DataOutputStream(context.openFileOutput(SCRIPT_NAME_miracle, 0)); fout_miracle.writeBytes(command); fout_miracle.close();//from w w w. j av a2 s . c om String[] args_miracle = new String[] { "su", "-c", ". " + context.getFilesDir().getAbsolutePath() + "/" + SCRIPT_NAME_miracle }; Process proc_miracle = Runtime.getRuntime().exec(args_miracle); return proc_miracle; }
From source file:com.trsst.client.MultiPartRequestEntity.java
private static void writeEntry(Base base, DataOutputStream out) throws IOException { out.writeBytes("content-type: " + MimeTypeHelper.getMimeType(base) + "\r\n\r\n"); base.writeTo(out);//from w w w . ja v a 2 s. co m }
From source file:editor.util.URLUtil.java
public static String sendPost(String url, String data) throws Exception { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); //add reuqest header con.setRequestMethod("POST"); // Send post request con.setDoOutput(true);//from w w w. j a va 2 s . c o m DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(data); wr.flush(); wr.close(); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); }
From source file:Main.java
public static List<String> execAsAdmin(String... commands) throws Exception { List<String> res = new ArrayList<String>(); Process process = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(process.getOutputStream()); for (String single : commands) { os.writeBytes(single + "\n"); os.flush();/*from ww w .j a v a2 s.c o m*/ //res.add(osRes.readLine()); } os.writeBytes("exit\n"); os.flush(); //process.destroy(); process.waitFor(); return res; }
From source file:Main.java
public static void GetSUAccess() { Thread su = new Thread(new Thread() { public void run() { try { Log.i("SU", "Trying to grant access to port..."); Process suProcess = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(suProcess.getOutputStream()); if (null != os) { os.writeBytes("chmod 666 /dev/ttymxc1 \n"); os.flush();//w ww . jav a 2s . c om } Log.i("SU", "Granted Access to Port"); } catch (IOException e) { Log.e("SU", "Grant SuperUser Access Failed"); } } }); su.start(); }
From source file:com.boubei.tss.modules.license.LicenseFactory.java
/** * ???//from w ww .j a va 2 s.c o m * ????hacker??license * @throws Exception */ public static void generateKey() throws Exception { KeyPairGenerator keyGen = KeyPairGenerator.getInstance(KEY_ALGORITHM); keyGen.initialize(1024, new SecureRandom()); KeyPair pair = keyGen.generateKeyPair(); PrivateKey priv = pair.getPrivate(); PublicKey pub = pair.getPublic(); log.info("?"); DataOutputStream out = new DataOutputStream(new FileOutputStream(PUBLIC_KEY_FILE)); out.writeBytes(EasyUtils.encodeHex(pub.getEncoded())); out.close(); log.info("??" + PUBLIC_KEY_FILE); out = new DataOutputStream(new FileOutputStream(PRIVATE_KEY_FILE)); out.writeBytes(EasyUtils.encodeHex(priv.getEncoded())); out.close(); log.info("??" + PRIVATE_KEY_FILE); }
From source file:org.apache.hadoop.hdfs.server.namenode.TestHARead.java
static void createFile(FileSystem fs, Path f) throws IOException { DataOutputStream a_out = fs.create(f); a_out.writeBytes("something"); a_out.close();//from w w w .j a v a2 s . c o m }
From source file:Main.java
public static void ExecuteNoReturn(String command, Boolean useroot, boolean forcenew) throws Exception { Process p;//from ww w. j a v a2 s . c om DataOutputStream os; p = getProcess(useroot, forcenew); os = new DataOutputStream(p.getOutputStream()); os.writeBytes(command + "\n"); if (forcenew) { os.writeBytes("exit\n"); os.flush(); os.close(); } //p.waitFor(); }