NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.sid;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class tcp extends Activity
{
public Socket ssco;
public BufferedReader sbuff;
public PrintStream sprs;

EditText sedt;
Button sbutn;
TextView stxtv;
Button bu1, nbu2;

int sin;
String ssrng;

class SocketListener implements Runnable
{
String stga;

public void run()
{
try
{
ssco = new Socket (ssrng, sin);
sbuff = new BufferedReader (new InputStreamReader(ssco.getInputStream()));
sprs = new PrintStream (ssco.getOutputStream());
sprs.println("Connection established");

while (true)
{
String s = sbuff.readLine ();
CharSequence cs = stxtv.getText ();
stga = cs + "rn" + s;

stxtv.post(new Runnable()
{
public void run()
{
stxtv.setText(stga);
}
}
);
}
}
catch (IOException e)
{
Log.e(getClass().getName(), e.getMessage());
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tcp);

stxtv = findViewById(R.id.vow);
stxtv.setMovementMethod(new ScrollingMovementMethod());

sedt = findViewById(R.id.sbut);


sin = 4444;
ssrng = "192.168.100.5";


bu1 = (Button)findViewById(R.id.savbut);
bu1.setOnClickListener(new View.OnClickListener()
{
public void onClick (View view)
{
String n = stxtv.getText().toString();

FileOutputStream fos;
try
{
fos = openFileOutput ("siddhu.txt", Context.MODE_PRIVATE);
fos.write (n.getBytes(), 0, n.length());
fos.close();
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
);

nbu2 = (Button)findViewById(R.id.load);
nbu2.setOnClickListener(new View.OnClickListener()
{
public void onClick (View view)
{
byte[] buffer = new byte[1024];
String s = "";
int n;

FileInputStream fin;
try
{
fin = openFileInput ("siddhu.txt");
do
{
n = fin.read (buffer, 0, 1024);

if ( n != -1)
{
s = s + new String (buffer, 0, n);
}

}
while ((n != -1));
fin.close();

stxtv.setText(s);
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}
);



Button hat= findViewById(R.id.shdp);
Button hate= findViewById(R.id.xxsopl);

hat.setOnClickListener(new View.OnClickListener()
{

@Override
public void onClick(View v)
{
Intent back = new Intent(tcp.this, Main2Activity.class);
startActivity(back);
}
});

hate.setOnClickListener(new View.OnClickListener()
{

@Override
public void onClick(View v)
{
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
});


sbutn = findViewById(R.id.sen);
sbutn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
new Thread()
{
public void run()
{
String s = sedt.getText().toString();
sprs.println (s);
}
}.start();
}
});

Thread rte = new Thread (new SocketListener ());
rte.start();
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.