Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onClick(View v) {
- String hID = id.getText().toString();
- String hName = name.getText().toString();
- String hLocation = location.getText().toString();
- String details = hID + " " + hName + " " + " " +hLocation+"\n";
- System.out.println(details);
- try {
- FileOutputStream fos = openFileOutput("file.txt",MODE_APPEND);
- fos.write(details.getBytes(StandardCharsets.UTF_8));
- System.out.println("Success");
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- public void onClick(View v) {
- try {
- FileInputStream fis = openFileInput("file.txt");
- InputStreamReader isr = new InputStreamReader(fis);
- BufferedReader br = new BufferedReader(isr);
- StringBuilder sb = new StringBuilder();
- String text;
- while((text = br.readLine())!=null)
- {
- sb.append(text);
- sb.append("\n");
- System.out.println(text+"Asd");
- }
- op.setText(sb.toString());
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement