Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a CSV file and replace text

Status
Not open for further replies.

GTLoco99

Programmer
Sep 2, 2003
59
US
Hello,

I am just learning Java and am trying to figure out how to open a CSV file and remove carriage returns from it. Is there anyone who can help point me in the right direction as far as any source code on how to do this, or somewhere on the internet i can read more about the built in methods of the java language

Thanks
GTLoco
 
Just to help you get a better idea of what i am trying to do. I did this same thing in VB 6, the code for it is below

Code:
_________________________

Public Sub Parse_File_Click()


Dim Path As String
Dim PathFld As TextBox
Dim textfile As File

Set PathFld = Me.Path_Name

Path = PathFld

Dim strFileData As String
Dim strFileReplace As String

Open Path For Input As #1

strFileData = Input(LOF(1), #1)
strFileReplace = Replace(strFileData, vbCrLf, "")

Close #1

Dim fso As New FileSystemObject, fil As File, ts As TextStream
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile ("c:\ParsedData.csv")
Set fil = fso.GetFile("c:\ParsedData.csv")
Set ts = fil.OpenAsTextStream(ForWriting)

ts.Write strFileReplace
ts.Close


MsgBox "Your file has been parsed. A new file has been created and saved at C:\ParsedData.csv", vbInformation, "Creation Successful"


End Sub
___________________________________

I want to do something simalar in Java, but have no clue what package to look in for the methods to open a file into a string and then replace text in it

Thanks
GTLoco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top