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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do not nunderstand what "\\" means

Status
Not open for further replies.

csphard

Programmer
Apr 5, 2002
194
US
I am trying to understand some java code we are using to unzip files.

What I do not understand is the part where it
says FileOutputStream(Extract_to+"\\"+str);
What does "\\" this mean.. Why not just "\"
I am guesting that these \\ is extract_to\str

"\\" this is not an operator right?

howard



create or replace and compile java source named "myjavaunzip"
as
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.text.*;
import java.lang.*;

class myjavaunzip
{
public static void unzip(String zip_name,String Extract_to)
throws Exception
{
ZipEntry ze;
String str;
int n=0;
FileInputStream fis=new FileInputStream(zip_name);
ZipInputStream zis=new ZipInputStream(fis);
while (true)
{
ze=zis.getNextEntry();
if (ze==null)
break;
str=ze.getName();
int x = fis.available();
byte [] rgb = new byte [x];
FileOutputStream fout = new FileOutputStream(Extract_to+"\\"+str);
while((n=zis.read(rgb))>-1)
{
fout.write(rgb,0,n);
}
fout.close();
zis.closeEntry();
}
zis.close();
fis.close();
}
}
/

 
Hi,

you build up a string here with the parts:
value of the variable Extract_to
the string \
value of the variable str

You have to escape the \ otherwise the tailing double quote would be part of the string and you get a syntax error because the string is not closed with a double quote.

I.e. you want to print out the string

Hello "my" world

You would do something like that: System.out.println("Hello \"my\" world")

Take a look at maybe this is more clear than my explanations ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top