How to use filename method of prog Package

Best Syzkaller code snippet using prog.filename

program.go

Source:program.go Github

copy

Full Screen

...37 initiated bool38 // fset the file set for this program39 fset *token.FileSet40 // created[i] contains the initial package whose ASTs or41 // filenames were supplied by AddFiles(), MustAddFiles()42 // and LoadFile() followed by the external test package,43 // if any, of each package in Import(), ImportWithTests(),44 // LoadPkgs and LoadPkgsWithTests() ordered by ImportPath.45 //46 // NOTE: these loaderFiles must not import "C". Cgo preprocessing is47 // only performed on imported packages, not ad hoc packages.48 //49 created []*PackageInfo50 // imported contains the initially imported packages,51 // as specified by Import(), ImportWithTests(), LoadPkgs and LoadPkgsWithTests().52 imported map[string]*PackageInfo53 // allPackages contains the PackageInfo of every package54 // encountered by Load: all initial packages and all55 // dependencies, including incomplete ones.56 allPackages map[*types.Package]*PackageInfo57 // We use token.File, not filename, since a file may appear to58 // belong to multiple packages and be parsed more than once.59 // token.File captures this distinction; filename does not.60 filesToUpdate map[*token.File]bool61 // <filename, codes> Non file Sources62 nonfileSources map[string][]byte63}64// LoadFile parses the source code of a single Go file and loads a new program.65//66// src specifies the parser input as a string, []byte, or io.Reader, and67// filename is its apparent name. If src is nil, the contents of68// filename are read from the file system.69//70func LoadFile(filename string, src interface{}) (*Program, error) {71 return NewProgram().AddFile(filename, src).Load()72}73// LoadDirs parses the source code of Go loaderFiles under the directories and loads a new program.74func LoadDirs(dirs ...string) (*Program, error) {75 p := NewProgram()76 srcs, _ := goutil.StringsConvert(build.Default.SrcDirs(), func(s string) (string, error) {77 return s + string(filepath.Separator), nil78 })79 for _, dir := range dirs {80 if !filepath.IsAbs(dir) {81 dir, _ = filepath.Abs(dir)82 }83 err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {84 if err != nil || !f.IsDir() {85 return nil86 }87 for _, src := range srcs {88 pkg := strings.TrimPrefix(path, src)89 if pkg != path {90 p.Import(pkg)91 }92 }93 return nil94 })95 if err != nil {96 return nil, err97 }98 }99 return p.Load()100}101// LoadPkgs imports packages and loads a new program.102//103// the set of initial source packages located relative to $GOPATH.104//105func LoadPkgs(pkgPath ...string) (*Program, error) {106 return NewProgram().Import(pkgPath...).Load()107}108// LoadPkgsWithTests imports packages and loads a new program.109//110// the set of initial source packages located relative to $GOPATH.111//112// The package will be augmented by any *_test.go loaderFiles in113// its directory that contain a "package x" (not "package x_test")114// declaration.115//116// In addition, if any *_test.go loaderFiles contain a "package x_test"117// declaration, an additional package comprising just those loaderFiles will118// be added to CreatePkgs.119//120func LoadPkgsWithTests(pkgPath ...string) (*Program, error) {121 return NewProgram().ImportWithTests(pkgPath...).Load()122}123// NewProgram creates a empty program.124func NewProgram() *Program {125 prog := new(Program)126 prog.filesToUpdate = make(map[*token.File]bool, 128)127 prog.conf.ParserMode = parser.ParseComments128 // Optimization: don't type-check the bodies of functions in our129 // dependencies, since we only need exported package members.130 prog.conf.TypeCheckFuncBodies = func(p string) bool {131 pp := strings.TrimSuffix(p, "_test")132 for _, cp := range prog.conf.CreatePkgs {133 if cp.Path == p || cp.Path == pp {134 return true135 }136 }137 for k := range prog.conf.ImportPkgs {138 if k == p || k == pp {139 return true140 }141 }142 return false143 }144 // Ideally we would just return conf.Load() here, but go/types145 // reports certain "soft" errors that gc does not (Go issue 14596).146 // As a workaround, we set AllowErrors=true and then duplicate147 // the loader's error checking but allow soft errors.148 // It would be nice if the loader API permitted "AllowErrors: soft".149 prog.conf.AllowErrors = true150 prog.conf.TypeChecker.DisableUnusedImportCheck = true151 prog.nonfileSources = make(map[string][]byte)152 return prog153}154// AddFile parses the source code of a single Go source file.155//156// src specifies the parser input as a string, []byte, or io.Reader, and157// filename is its apparent name. If src is nil, the contents of158// filename are read from the file system.159//160// filename is used to rewrite to local file;161// if empty, rewrite to self-increasing number filename under the package name path.162//163func (prog *Program) AddFile(filename string, src interface{}) (itself *Program) {164 if !prog.initiated && prog.initialError == nil {165 var _src interface{}166 b, srcErr := tools.ReadSourceBytes(src)167 if b != nil {168 _src = b169 }170 f, err := prog.conf.ParseFile(filename, _src)171 if err != nil {172 prog.initialError = err173 } else {174 if filename == "" {175 filename = autoFilename(f)176 }177 prog.conf.CreateFromFiles(f.Name.Name, &loader.File{Filename: filename, File: f})178 if srcErr == nil {179 prog.nonfileSources[filename] = b180 }181 }182 }183 return prog184}185// Import imports packages that will be imported from source,186// the set of initial source packages located relative to $GOPATH.187func (prog *Program) Import(pkgPath ...string) (itself *Program) {188 if !prog.initiated && prog.initialError == nil {189 for _, p := range pkgPath {190 prog.conf.Import(p)191 }192 }193 return prog194}195// ImportWithTests imports packages that will be imported from source,196// the set of initial source packages located relative to $GOPATH.197// The package will be augmented by any *_test.go loaderFiles in198// its directory that contain a "package x" (not "package x_test")199// declaration.200//201// In addition, if any *_test.go loaderFiles contain a "package x_test"202// declaration, an additional package comprising just those loaderFiles will203// be added to CreatePkgs.204//205func (prog *Program) ImportWithTests(pkgPath ...string) (itself *Program) {206 if !prog.initiated && prog.initialError == nil {207 for _, p := range pkgPath {208 prog.conf.ImportWithTests(p)209 }210 }211 return prog212}213// Load loads the program's packages,214// and loads their dependencies packages as needed.215//216// On failure, returns an error.217// It is an error if no packages were loaded.218//219func (prog *Program) Load() (itself *Program, err error) {220 if prog.initiated {221 return prog, errors.New("can not load two times")222 }223 if prog.initialError != nil {224 return prog, prog.initialError225 }226 prog.initiated = true227 defer func() {228 if p := recover(); p != nil {229 err = fmt.Errorf("%v", p)230 prog.initialError = err231 fmt.Printf("panic:%v\n%s", err, goutil.PanicTrace(1))232 }233 }()234 p, err := prog.conf.Load()235 if err != nil {236 prog.initialError = err237 return prog, prog.initialError238 }239 // Allow exist error240 // var errpkgs []string241 // // Report hard errors in indirectly imported packages.242 // for _, info := range p.AllPackages {243 // if containsHardErrors(info.Errors) {244 // errpkgs = append(errpkgs, info.Pkg.Path())245 // }246 // }247 // if errpkgs != nil {248 // var more string249 // if len(errpkgs) > 3 {250 // more = fmt.Sprintf(" and %d more", len(errpkgs)-3)251 // errpkgs = errpkgs[:3]252 // }253 // prog.initialError = fmt.Errorf("couldn't load packages due to errors: %s%s",254 // strings.Join(errpkgs, ", "), more)255 // return prog, prog.initialError256 // }257 return prog.convert(p), nil258}259// MustLoad is the same as Load(), but panic when error occur.260func (prog *Program) MustLoad() (itself *Program) {261 _, err := prog.Load()262 if err != nil {263 panic(err)264 }265 return prog266}267func (prog *Program) convert(p *loader.Program) (itself *Program) {268 prog.fset = p.Fset269 prog.imported = make(map[string]*PackageInfo, len(prog.imported))270 prog.allPackages = make(map[*types.Package]*PackageInfo, len(prog.allPackages))271 var solved = make(map[*loader.PackageInfo]*PackageInfo, len(p.AllPackages))272 for _, info := range p.Created {273 newInfo := newPackageInfo(prog, info)274 solved[info] = newInfo275 prog.created = append(prog.created, newInfo)276 }277 for k, info := range p.Imported {278 newInfo := newPackageInfo(prog, info)279 solved[info] = newInfo280 prog.imported[k] = newInfo281 }282 for k, info := range p.AllPackages {283 if newInfo, ok := solved[info]; ok {284 prog.allPackages[k] = newInfo285 } else {286 newInfo := newPackageInfo(prog, info)287 solved[info] = newInfo288 prog.allPackages[k] = newInfo289 }290 }291 prog.check()292 return prog293}294func (prog *Program) check() {295 for _, pkg := range prog.InitialPackages() {296 pkg.check()297 }298}299// InitialPackages returns a new slice containing the set of initial300// packages (created + imported) in unspecified order.301func (prog *Program) InitialPackages() []*PackageInfo {302 pkgs := make([]*PackageInfo, 0, len(prog.created)+len(prog.imported))303 pkgs = append(pkgs, prog.created...)304 for _, pkg := range prog.imported {305 pkgs = append(pkgs, pkg)306 }307 return pkgs308}309// Package returns the ASTs and results of type checking for the310// specified package.311// NOTE: return nil, if the package does not exist.312func (prog *Program) Package(path string) *PackageInfo {313 for k, v := range prog.allPackages {314 if k.Path() == path {315 return v316 }317 }318 for _, info := range prog.created {319 if path == info.Pkg.Path() {320 return info321 }322 }323 return nil324}325// pathEnclosingInterval returns the PackageInfo and ast.Node that326// contain source interval [start, end), and all the node's ancestors327// up to the AST root. It searches all ast.Files of all packages in prog.328// exact is defined as for astutil.PathEnclosingInterval.329//330// The zero value is returned if not found.331//332func (prog *Program) pathEnclosingInterval(start, end token.Pos) (pkg *PackageInfo, file *loader.File, path []ast.Node, exact bool) {333 for _, pkg = range prog.allPackages {334 file, path, exact = pkg.pathEnclosingInterval(start, end)335 if path != nil {336 return337 }338 }339 return nil, nil, nil, false340}341func (prog *Program) source(filename string) ([]byte, error) {342 src, ok := prog.nonfileSources[filename]343 if ok {344 return src, nil345 }346 return tools.ReadSource(filename, nil)347}348func containsHardErrors(errors []error) bool {349 for _, err := range errors {350 if err, ok := err.(types.Error); ok && err.Soft {351 continue352 }353 return true354 }355 return false356}357func tokenFileContainsPos(f *token.File, pos token.Pos) bool {358 p := int(pos)359 base := f.Base()360 return base <= p && p < base+f.Size()...

Full Screen

Full Screen

strategy.go

Source:strategy.go Github

copy

Full Screen

...118 file, e := os.CreateTemp("", "strategy*.o")119 if e != nil {120 return nil, e121 }122 filename := file.Name()123 defer os.Remove(filename)124 if _, e := file.Write(elf); e != nil {125 return nil, e126 }127 file.Close()128 return LoadFile(name, filename)129}130// LoadFile loads a strategy BPF program from ELF file.131// If filename is empty, search for an ELF file in default locations.132func LoadFile(name, filename string) (sc *Strategy, e error) {133 if filename == "" {134 filename, e = bpf.Strategy.Find(name)135 if e != nil {136 return nil, e137 }138 }139 elfFile, e := elf.Open(filename)140 if e != nil {141 return nil, e142 }143 defer elfFile.Close()144 tableLock.Lock()145 defer tableLock.Unlock()146 lastID++147 sc = &Strategy{148 c: eal.Zmalloc[C.StrategyCode]("Strategy", C.sizeof_StrategyCode, eal.NumaSocket{}),149 id: lastID,150 name: name,151 }152 defer func(sc *Strategy) {153 if e != nil {154 sc.free()155 }156 }(sc)157 if sec := elfFile.Section(C.SGSEC_MAIN); sec != nil {158 if sc.c.main, e = makeProg(filename, C.SGSEC_MAIN, XsymsMain); e != nil {159 return nil, fmt.Errorf("jit-compile %s: %w", C.SGSEC_MAIN, e)160 }161 } else {162 return nil, fmt.Errorf("missing %s section", C.SGSEC_MAIN)163 }164 if sec := elfFile.Section(C.SGSEC_INIT); sec != nil {165 if sc.init, e = makeProg(filename, C.SGSEC_INIT, XsymsInit); e != nil {166 return nil, fmt.Errorf("jit-compile %s: %w", C.SGSEC_INIT, e)167 }168 }169 if sec := elfFile.Section(C.SGSEC_SCHEMA); sec != nil {170 text, e := sec.Data()171 if e != nil {172 return nil, fmt.Errorf("read %s: %w", C.SGSEC_SCHEMA, e)173 }174 sc.schema, e = gojsonschema.NewSchema(gojsonschema.NewBytesLoader(text))175 if e != nil {176 return nil, fmt.Errorf("load %s: %w", C.SGSEC_SCHEMA, e)177 }178 }179 table[sc.id] = sc180 sc.c.id = C.int(sc.id)181 sc.c.goHandle = C.uintptr_t(cgo.NewHandle(sc))182 C.StrategyCode_Ref(sc.c)183 return sc, nil184}185// MakeEmpty returns an empty strategy for unit testing.186// Panics on error.187func MakeEmpty(name string) *Strategy {188 filename, e := bpf.Strategy.Find("empty")189 if e != nil {190 logger.Panic("MakeEmpty error", zap.Error(e))191 }192 sc, e := LoadFile(name, filename)193 if e != nil {194 logger.Panic("MakeEmpty error", zap.Error(e))195 }196 return sc197}198func makeProg(filename, section string, xsyms Xsyms) (prog C.StrategyCodeProg, e error) {199 filenameC, sectionC := C.CString(filename), C.CString(section)200 defer func() {201 C.free(unsafe.Pointer(filenameC))202 C.free(unsafe.Pointer(sectionC))203 }()204 var prm C.struct_rte_bpf_prm205 prm.xsym, prm.nb_xsym = xsyms.ptr, xsyms.n206 prm.prog_arg._type = C.RTE_BPF_ARG_RAW207 prog.bpf = C.rte_bpf_elf_load(&prm, filenameC, sectionC)208 if prog.bpf == nil {209 return C.StrategyCodeProg{}, eal.GetErrno()210 }211 var jit C.struct_rte_bpf_jit212 if res := C.rte_bpf_get_jit(prog.bpf, &jit); res != 0 {213 C.rte_bpf_destroy(prog.bpf)214 return C.StrategyCodeProg{}, eal.MakeErrno(res)215 }216 prog.jit = jit._func217 return prog, nil218}219func freeProg(prog C.StrategyCodeProg) {220 if prog.bpf != nil {221 C.rte_bpf_destroy(prog.bpf)...

Full Screen

Full Screen

cha_test.go

Source:cha_test.go Github

copy

Full Screen

...41// TestCHA runs CHA on each file in inputs, prints the dynamic edges of42// the call graph, and compares it with the golden results embedded in43// the WANT comment at the end of the file.44func TestCHA(t *testing.T) {45 for _, filename := range inputs {46 prog, f, mainPkg, err := loadProgInfo(filename, ssa.InstantiateGenerics)47 if err != nil {48 t.Error(err)49 continue50 }51 want, pos := expectation(f)52 if pos == token.NoPos {53 t.Error(fmt.Errorf("No WANT: comment in %s", filename))54 continue55 }56 cg := cha.CallGraph(prog)57 if got := printGraph(cg, mainPkg.Pkg, "dynamic", "Dynamic calls"); got != want {58 t.Errorf("%s: got:\n%s\nwant:\n%s",59 prog.Fset.Position(pos), got, want)60 }61 }62}63// TestCHAGenerics is TestCHA tailored for testing generics,64func TestCHAGenerics(t *testing.T) {65 if !typeparams.Enabled {66 t.Skip("TestCHAGenerics requires type parameters")67 }68 filename := "testdata/generics.go"69 prog, f, mainPkg, err := loadProgInfo(filename, ssa.InstantiateGenerics)70 if err != nil {71 t.Fatal(err)72 }73 want, pos := expectation(f)74 if pos == token.NoPos {75 t.Fatal(fmt.Errorf("No WANT: comment in %s", filename))76 }77 cg := cha.CallGraph(prog)78 if got := printGraph(cg, mainPkg.Pkg, "", "All calls"); got != want {79 t.Errorf("%s: got:\n%s\nwant:\n%s",80 prog.Fset.Position(pos), got, want)81 }82}83func loadProgInfo(filename string, mode ssa.BuilderMode) (*ssa.Program, *ast.File, *ssa.Package, error) {84 content, err := ioutil.ReadFile(filename)85 if err != nil {86 return nil, nil, nil, fmt.Errorf("couldn't read file '%s': %s", filename, err)87 }88 conf := loader.Config{89 ParserMode: parser.ParseComments,90 }91 f, err := conf.ParseFile(filename, content)92 if err != nil {93 return nil, nil, nil, err94 }95 conf.CreateFromFiles("main", f)96 iprog, err := conf.Load()97 if err != nil {98 return nil, nil, nil, err99 }100 prog := ssautil.CreateProgram(iprog, mode)101 prog.Build()102 return prog, f, prog.Package(iprog.Created[0].Pkg), nil103}104// printGraph returns a string representation of cg involving only edges105// whose description contains edgeMatch. The string representation is...

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("The name of the program is", prog)4 fmt.Println("The name of the program is", prog.filename())5}6import (7func main() {8 fmt.Println("The name of the program is", prog)9 fmt.Println("The name of the program is", prog.filename())10}11import (12func main() {13 fmt.Println("The name of the program is", prog)14 fmt.Println("The name of the program is", prog.filename())15}16import (17func main() {18 fmt.Println("The name of the program is", prog)19 fmt.Println("The name of the program is", prog.filename())20}21import (22func main() {23 fmt.Println("The name of the program is", prog)24 fmt.Println("The name of the program is", prog.filename())25}26import (27func main() {28 fmt.Println("The name of the program is", prog)29 fmt.Println("The name of the program is", prog.filename())30}31import (32func main() {33 fmt.Println("The name of the program is", prog)34 fmt.Println("The name of the program is", prog.filename())35}

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import prog.*;2public class Two {3 public static void main(String[] args) {4 Prog p = new Prog();5 System.out.println(p.filename());6 }7}8package prog;9public class Prog {10 public String filename() {11 return "Prog.java";12 }13}14import prog.*;15public class Two {16 public static void main(String[] args) {17 Prog p = new Prog();18 System.out.println(p.filename());19 }20}21package prog;22public class Prog {23 public String filename() {24 return "Prog.java";25 }26}27package prog;28public class Prog {29 public String filename() {30 return "Prog.class";31 }32}33package prog;34public class Prog {35 public String filename() {36 return "Prog.java";37 }38}39import prog.*;40public class Two {41 public static void main(String[] args) {42 Prog p = new Prog();43 System.out.println(p.filename());44 }45}46package prog;47public class Prog {48 public String filename() {49 return "Prog.java";50 }51}52package prog;53public class Prog {54 public String filename() {55 return "Prog.class";56 }57}58package prog;59public class Prog {60 public String filename() {61 return "Prog.java";62 }63}64package prog;65public class Prog {66 public String filename() {67 return "Prog.class";68 }69}70package prog;71public class Prog {72 public String filename() {73 return "Prog.java";74 }75}76package prog;77public class Prog {78 public String filename() {79 return "Prog.class";80 }81}82package prog;83public class Prog {84 public String filename() {85 return "Prog.java";86 }87}88package prog;

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static void main(String[] args) {3 Prog p = new Prog();4 System.out.println(p.filename());5 }6}7import (8func filename() string {9 path, _ := os.Executable()10}11func main() {12 fmt.Println(filename())13}14import (15func main() {16 fmt.Println(filename())17}

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main(){3 fmt.Println(prog.filename())4}5import "fmt"6func filename() string {7}8func main(){9 fmt.Println(filename())10}

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(golenv.Filename())4}5import (6func main() {7 fmt.Println(golenv.Dirname())8}9import (10func main() {11 fmt.Println(golenv.Filebase())12}13import (14func main() {15 fmt.Println(golenv.Fileext())16}17import (18func main() {19 fmt.Println(golenv.Filefullpath())20}21import (22func main() {23 fmt.Println(golenv.Filefullpath())24}25import (26func main() {27 fmt.Println(golenv.Filefullpath())28}29import (30func main() {31 fmt.Println(golenv.Filefullpath())32}33import (34func main() {35 fmt.Println(golenv.Filefullpath())36}

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("filename is: ", filename)4}5import (6func main() {7 fmt.Println("path is: ", path)8}9import (10func main() {11 fmt.Println("name is: ", name)12}13import (14func main() {15 fmt.Println("args is: ", args)16}17import (18func main() {19 env := os.Environ()20 fmt.Println("env is: ", env)21}22env is: [ALLUSERSPROFILE=C:\ProgramData, APPDATA=C:\Users\user\AppData\Roaming, CLASSPATH=.;C:\Program Files\Java\jdk1.8.0_221\lib, CommonProgramFiles=C:\Program Files\Common Files, CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files, CommonProgramW6432=C:\Program Files\Common Files, COMPUTERNAME=USER-PC, ComSpec=C:\Windows\system32\cmd.exe, DRIVERDATA=C:\Windows\System32\Drivers\

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Printf("The filename is: %s4", filepath.Base(os.Args[0]))5}6import (7func main() {8 fmt.Printf("The filename is: %s9}10import (11func main() {12 fmt.Printf("The filename is: %s13}14import (15func main() {16 fmt.Printf("The filename is: %s17}18import (19func main() {20 fmt.Printf("The filename is: %s21}22import (23func main() {24 fmt.Printf("The filename is: %s25}26import (27func main() {28 fmt.Printf("The filename is: %s29}30import (31func main() {32 fmt.Printf("The filename is: %s33}

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "os"3import "path/filepath"4func main() {5 fmt.Println("Program name = ", filepath.Base(os.Args[0]))6}7import "fmt"8import "os"9import "path/filepath"10func main() {11 fmt.Println("Working directory = ", filepath.Dir(os.Args[0]))12}13import "fmt"14import "os"15import "path/filepath"16func main() {17 fmt.Println("Is absolute path = ", filepath.IsAbs(os.Args[0]))18}19import "fmt"20import "os"21import "path/filepath"22func main() {23 dir, file := filepath.Split(os.Args[0])24 fmt.Println("Directory = ", dir)25 fmt.Println("File = ", file)26}27import "fmt"28import "os"29import "path/filepath"30func main() {31 fmt.Println("Join = ", filepath.Join("C:", "Users", "User", "Desktop"))32}33import "fmt"34import "os"35import "path/filepath"36func main() {37 file, ext := filepath.Ext(os.Args[0])38 fmt.Println("File = ", file)39 fmt.Println("Extension = ", ext)40}41import "fmt"42import "path/filepath"43func main() {44 fmt.Println("Split list = ", filepath.SplitList("C:\\Users\\User\\Desktop"))45}46import "fmt"47import "path/filepath"48func main() {

Full Screen

Full Screen

filename

Using AI Code Generation

copy

Full Screen

1public class 2 {2 public static void main(String[] args) {3 String path = "C:\\Users\\User\\Desktop\\Java\\prog.java";4 File file = new File(path);5 System.out.println("The filename is: " + file.getName());6 }7}8public class 3 {9 public static void main(String[] args) {10 String path = "C:\\Users\\User\\Desktop\\Java\\prog.java";11 File file = new File(path);12 System.out.println("The length of file is: " + file.length());13 }14}15public class 4 {16 public static void main(String[] args) {17 String path = "C:\\Users\\User\\Desktop\\Java\\prog.java";18 File file = new File(path);19 System.out.println("The last modified date of file is: " + file.lastModified());20 }21}22public class 5 {23 public static void main(String[] args) {24 String path = "C:\\Users\\User\\Desktop\\Java\\prog.java";25 File file = new File(path);26 System.out.println("The file exists: " + file.exists());27 }28}29public class 6 {30 public static void main(String[] args) {31 String path = "C:\\Users\\User\\Desktop\\Java\\prog.java";32 File file = new File(path);33 System.out.println("The file is a directory:

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful