Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. help me please

help me please

Scheduled Pinned Locked Moved Java
javahelptutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    terzasek
    wrote on last edited by
    #1

    how to write main class for run this class. 1. edit this class. 2. create main class for run I need to write , read text file path C:\\file.txt anyone help me please. package import java.io.*; public class TextFileOperator { public TextFileOperator(String path){ f = new File(path); } File f; public void write(String text, boolean isAppend){ FileOutputStream out = new FileOutputStream(f,isAppend); OutputStreamWriter wr = new OutputStreamWriter(out); wr.write(text); wr.close(); out.close(); } public String read() { FileReader reader = new FileReader(f); BufferedReader bf = new BufferedReader(reader); StringBuilder bd = new StringBuilder(); String s; while((s = bf.readLine()) != null){ bd.append(s); bd.append("\n"); } return bd.toString(); } }

    L A 2 Replies Last reply
    0
    • T terzasek

      how to write main class for run this class. 1. edit this class. 2. create main class for run I need to write , read text file path C:\\file.txt anyone help me please. package import java.io.*; public class TextFileOperator { public TextFileOperator(String path){ f = new File(path); } File f; public void write(String text, boolean isAppend){ FileOutputStream out = new FileOutputStream(f,isAppend); OutputStreamWriter wr = new OutputStreamWriter(out); wr.write(text); wr.close(); out.close(); } public String read() { FileReader reader = new FileReader(f); BufferedReader bf = new BufferedReader(reader); StringBuilder bd = new StringBuilder(); String s; while((s = bf.readLine()) != null){ bd.append(s); bd.append("\n"); } return bd.toString(); } }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Take a look at the Java Tutorials[^]. You just need to add something of the form:

      public static void main(String args[])
      {
      // add method calls to your other code here
      }

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      • T terzasek

        how to write main class for run this class. 1. edit this class. 2. create main class for run I need to write , read text file path C:\\file.txt anyone help me please. package import java.io.*; public class TextFileOperator { public TextFileOperator(String path){ f = new File(path); } File f; public void write(String text, boolean isAppend){ FileOutputStream out = new FileOutputStream(f,isAppend); OutputStreamWriter wr = new OutputStreamWriter(out); wr.write(text); wr.close(); out.close(); } public String read() { FileReader reader = new FileReader(f); BufferedReader bf = new BufferedReader(reader); StringBuilder bd = new StringBuilder(); String s; while((s = bf.readLine()) != null){ bd.append(s); bd.append("\n"); } return bd.toString(); } }

        A Offline
        A Offline
        Avidwan
        wrote on last edited by
        #3

        I want to learn java programming... after that i'll create a website for java , c , c++ programming tutorials specially for beginners, just like me..:)

        L 1 Reply Last reply
        0
        • A Avidwan

          I want to learn java programming... after that i'll create a website for java , c , c++ programming tutorials specially for beginners, just like me..:)

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          :confused:

          One of these days I'm going to think of a really clever signature.

          C 1 Reply Last reply
          0
          • L Lost User

            :confused:

            One of these days I'm going to think of a really clever signature.

            C Offline
            C Offline
            cubocik
            wrote on last edited by
            #5

            May you please encote correctly your code and post what errors you have ?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups